@layerzerolabs/protocol-stellar-v2 0.2.15 → 0.2.19

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 (262) hide show
  1. package/.turbo/turbo-build.log +365 -297
  2. package/.turbo/turbo-lint.log +142 -110
  3. package/.turbo/turbo-test.log +1273 -1222
  4. package/Cargo.lock +20 -5
  5. package/Cargo.toml +4 -1
  6. package/contracts/ERROR_SPEC.md +44 -0
  7. package/contracts/common-macros/src/auth.rs +113 -0
  8. package/contracts/common-macros/src/contract_ttl.rs +84 -0
  9. package/contracts/common-macros/src/lib.rs +181 -30
  10. package/contracts/common-macros/src/lz_contract.rs +83 -0
  11. package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
  12. package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
  13. package/contracts/common-macros/src/tests/mod.rs +2 -2
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
  16. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap → common_macros__tests__auth__snapshot_only_auth_preserves_function_signature.snap} +4 -4
  17. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap → common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap} +3 -3
  18. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
  19. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -21
  20. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +2 -2
  21. package/contracts/common-macros/src/ttl_configurable.rs +19 -34
  22. package/contracts/common-macros/src/ttl_extendable.rs +36 -0
  23. package/contracts/common-macros/src/upgradeable.rs +5 -5
  24. package/contracts/common-macros/src/utils.rs +9 -0
  25. package/contracts/endpoint-v2/src/constants.rs +4 -4
  26. package/contracts/endpoint-v2/src/endpoint_v2.rs +38 -40
  27. package/contracts/endpoint-v2/src/errors.rs +4 -3
  28. package/contracts/endpoint-v2/src/events.rs +1 -1
  29. package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
  30. package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
  31. package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
  32. package/contracts/endpoint-v2/src/storage.rs +1 -1
  33. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +3 -3
  34. package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +1 -1
  35. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
  36. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +3 -3
  37. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
  38. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +3 -3
  39. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +1 -1
  40. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +3 -3
  41. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +1 -1
  42. package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +4 -4
  43. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +1 -1
  44. package/contracts/layerzero-views/src/layerzero_view.rs +3 -6
  45. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +2 -2
  46. package/contracts/macro-integration-tests/tests/runtime/ownable/{only_owner_guard.rs → only_auth_guard.rs} +1 -1
  47. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +1 -1
  48. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +1 -1
  49. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +0 -1
  50. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.rs → only_auth_missing_env.rs} +3 -3
  51. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.stderr → only_auth_missing_env.stderr} +4 -4
  52. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +2 -3
  53. package/contracts/macro-integration-tests/tests/ui/ownable/pass/{only_owner_env_param_variants.rs → only_auth_env_param_variants.rs} +9 -9
  54. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +6 -6
  55. package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
  56. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +3 -3
  57. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +1 -2
  58. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +1 -2
  59. package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +9 -9
  60. package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +1 -1
  61. package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +1 -1
  62. package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +2 -2
  63. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
  64. package/contracts/message-libs/treasury/src/errors.rs +2 -2
  65. package/contracts/message-libs/treasury/src/events.rs +1 -1
  66. package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
  67. package/contracts/message-libs/treasury/src/storage.rs +1 -1
  68. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
  69. package/contracts/message-libs/treasury/src/treasury.rs +14 -16
  70. package/contracts/message-libs/uln-302/src/receive_uln.rs +13 -2
  71. package/contracts/message-libs/uln-302/src/send_uln.rs +24 -4
  72. package/contracts/message-libs/uln-302/src/uln302.rs +6 -24
  73. package/contracts/oapps/counter/Cargo.toml +14 -1
  74. package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
  75. package/contracts/oapps/counter/integration_tests/{setup.rs → setup_sml.rs} +48 -80
  76. package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
  77. package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
  78. package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
  79. package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
  80. package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
  81. package/contracts/oapps/counter/src/counter.rs +67 -43
  82. package/contracts/oapps/counter/src/tests/mod.rs +0 -13
  83. package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
  84. package/contracts/oapps/oapp/src/errors.rs +5 -1
  85. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +93 -78
  86. package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
  87. package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
  88. package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
  89. package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
  90. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -8
  91. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -17
  92. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -7
  93. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -15
  94. package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
  95. package/contracts/oapps/oapp-macros/src/lib.rs +113 -56
  96. package/contracts/oapps/oft/Cargo.toml +10 -7
  97. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_oft_fee.rs +3 -4
  98. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_pausable.rs +2 -3
  99. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_rate_limiter.rs +1 -1
  100. package/contracts/oapps/oft/integration-tests/mod.rs +1 -1
  101. package/contracts/oapps/oft/integration-tests/setup.rs +29 -110
  102. package/contracts/oapps/oft/integration-tests/utils.rs +254 -21
  103. package/contracts/oapps/oft/src/extensions/oft_fee.rs +13 -14
  104. package/contracts/oapps/oft/src/extensions/pausable.rs +4 -4
  105. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +5 -5
  106. package/contracts/oapps/oft/src/lib.rs +11 -13
  107. package/contracts/oapps/oft/src/oft.rs +147 -225
  108. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +9 -13
  109. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +31 -14
  110. package/contracts/oapps/oft/src/oft_types/mod.rs +13 -0
  111. package/contracts/oapps/{oft-std → oft-core}/Cargo.toml +6 -4
  112. package/contracts/oapps/{oft-std → oft-core}/integration-tests/mod.rs +1 -1
  113. package/contracts/oapps/{oft-std → oft-core}/integration-tests/setup.rs +129 -30
  114. package/contracts/oapps/{oft → oft-core}/integration-tests/test_with_sml.rs +3 -3
  115. package/contracts/oapps/oft-core/integration-tests/utils.rs +201 -0
  116. package/contracts/oapps/oft-core/src/errors.rs +13 -0
  117. package/contracts/oapps/oft-core/src/lib.rs +18 -0
  118. package/contracts/oapps/oft-core/src/oft_core.rs +439 -0
  119. package/contracts/oapps/{oft → oft-core}/src/storage.rs +2 -0
  120. package/contracts/oapps/{oft → oft-core}/src/tests/mod.rs +0 -2
  121. package/contracts/oapps/{oft → oft-core}/src/tests/test_decimals.rs +2 -2
  122. package/contracts/oapps/{oft → oft-core}/src/tests/test_lz_receive.rs +7 -7
  123. package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_msg_codec.rs +4 -5
  124. package/contracts/oapps/{oft → oft-core}/src/tests/test_resolve_address.rs +3 -3
  125. package/contracts/oapps/{oft → oft-core}/src/tests/test_utils.rs +78 -37
  126. package/contracts/oapps/oft-core/src/types.rs +58 -0
  127. package/contracts/oapps/{oft → oft-core}/src/utils.rs +1 -1
  128. package/contracts/upgrader/src/lib.rs +4 -4
  129. package/contracts/utils/src/auth.rs +44 -0
  130. package/contracts/utils/src/errors.rs +31 -5
  131. package/contracts/utils/src/lib.rs +3 -0
  132. package/contracts/utils/src/multisig.rs +211 -0
  133. package/contracts/utils/src/ownable.rs +137 -13
  134. package/contracts/utils/src/tests/buffer_reader.rs +6 -6
  135. package/contracts/utils/src/tests/buffer_writer.rs +6 -6
  136. package/contracts/utils/src/tests/bytes_ext.rs +2 -4
  137. package/contracts/utils/src/tests/mod.rs +1 -0
  138. package/contracts/utils/src/tests/multisig.rs +731 -0
  139. package/contracts/utils/src/tests/option_ext.rs +2 -5
  140. package/contracts/utils/src/tests/ownable.rs +456 -7
  141. package/contracts/utils/src/tests/ttl_configurable.rs +27 -16
  142. package/contracts/utils/src/tests/upgradeable.rs +4 -2
  143. package/contracts/utils/src/ttl_configurable.rs +23 -8
  144. package/contracts/utils/src/ttl_extendable.rs +27 -0
  145. package/contracts/utils/src/upgradeable.rs +2 -0
  146. package/contracts/workers/dvn/Cargo.toml +1 -1
  147. package/contracts/workers/dvn/src/auth.rs +7 -7
  148. package/contracts/workers/dvn/src/dvn.rs +10 -38
  149. package/contracts/workers/dvn/src/errors.rs +0 -7
  150. package/contracts/workers/dvn/src/events.rs +1 -14
  151. package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
  152. package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
  153. package/contracts/workers/dvn/src/storage.rs +3 -13
  154. package/contracts/workers/dvn/src/tests/auth.rs +4 -4
  155. package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
  156. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
  157. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
  158. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
  159. package/contracts/workers/dvn/src/tests/setup.rs +5 -5
  160. package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
  161. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +3 -6
  162. package/contracts/workers/executor/src/auth.rs +80 -16
  163. package/contracts/workers/executor/src/executor.rs +5 -31
  164. package/contracts/workers/executor/src/storage.rs +2 -9
  165. package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
  166. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +3 -6
  167. package/contracts/workers/executor-helper/Cargo.toml +1 -1
  168. package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
  169. package/contracts/workers/price-feed/Cargo.toml +1 -1
  170. package/contracts/workers/price-feed/src/price_feed.rs +7 -10
  171. package/contracts/workers/worker/src/errors.rs +4 -0
  172. package/contracts/workers/worker/src/tests/worker.rs +7 -6
  173. package/contracts/workers/worker/src/worker.rs +20 -16
  174. package/package.json +7 -5
  175. package/sdk/.turbo/turbo-build.log +1 -0
  176. package/sdk/.turbo/turbo-test.log +1019 -0
  177. package/sdk/dist/generated/bml.d.ts +95 -8
  178. package/sdk/dist/generated/bml.js +95 -36
  179. package/sdk/dist/generated/counter.d.ts +289 -44
  180. package/sdk/dist/generated/counter.js +119 -49
  181. package/sdk/dist/generated/dvn.d.ts +312 -229
  182. package/sdk/dist/generated/dvn.js +144 -83
  183. package/sdk/dist/generated/dvn_fee_lib.d.ts +258 -63
  184. package/sdk/dist/generated/dvn_fee_lib.js +95 -26
  185. package/sdk/dist/generated/endpoint.d.ts +219 -24
  186. package/sdk/dist/generated/endpoint.js +108 -41
  187. package/sdk/dist/generated/executor.d.ts +239 -87
  188. package/sdk/dist/generated/executor.js +135 -63
  189. package/sdk/dist/generated/executor_fee_lib.d.ts +278 -74
  190. package/sdk/dist/generated/executor_fee_lib.js +135 -59
  191. package/sdk/dist/generated/executor_helper.d.ts +163 -21
  192. package/sdk/dist/generated/executor_helper.js +124 -52
  193. package/sdk/dist/generated/oft.d.ts +1842 -0
  194. package/sdk/dist/generated/oft.js +345 -0
  195. package/sdk/dist/generated/price_feed.d.ts +258 -63
  196. package/sdk/dist/generated/price_feed.js +95 -26
  197. package/sdk/dist/generated/sml.d.ts +235 -34
  198. package/sdk/dist/generated/sml.js +126 -53
  199. package/sdk/dist/generated/treasury.d.ts +1016 -0
  200. package/sdk/dist/generated/treasury.js +248 -0
  201. package/sdk/dist/generated/uln302.d.ts +235 -34
  202. package/sdk/dist/generated/uln302.js +126 -53
  203. package/sdk/dist/generated/upgrader.d.ts +17 -2
  204. package/sdk/dist/generated/upgrader.js +19 -1
  205. package/sdk/dist/index.d.ts +2 -1
  206. package/sdk/dist/index.js +2 -1
  207. package/sdk/package.json +6 -3
  208. package/sdk/src/index.ts +2 -1
  209. package/sdk/test/counter-sml.test.ts +376 -0
  210. package/sdk/test/counter-uln.test.ts +493 -0
  211. package/sdk/test/{oft.test.ts → oft-sml.test.ts} +196 -321
  212. package/sdk/test/suites/constants.ts +22 -2
  213. package/sdk/test/suites/globalSetup.ts +450 -0
  214. package/sdk/test/suites/localnet.ts +23 -6
  215. package/sdk/test/upgrader.test.ts +7 -16
  216. package/sdk/test/utils.ts +558 -85
  217. package/sdk/turbo.json +8 -0
  218. package/sdk/vitest.config.ts +21 -0
  219. package/tools/ts-bindings-gen/Cargo.toml +2 -0
  220. package/tools/ts-bindings-gen/src/main.rs +52 -4
  221. package/contracts/common-macros/src/contract_impl.rs +0 -52
  222. package/contracts/common-macros/src/ownable.rs +0 -41
  223. package/contracts/common-macros/src/tests/contract_impl.rs +0 -386
  224. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -12
  225. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +0 -50
  226. package/contracts/oapps/oapp-macros/src/oapp_core.rs +0 -41
  227. package/contracts/oapps/oapp-macros/src/oapp_full.rs +0 -21
  228. package/contracts/oapps/oapp-macros/src/oapp_options_type3.rs +0 -31
  229. package/contracts/oapps/oapp-macros/src/oapp_receiver.rs +0 -48
  230. package/contracts/oapps/oapp-macros/src/oapp_sender.rs +0 -21
  231. package/contracts/oapps/oapp-macros/src/util.rs +0 -107
  232. package/contracts/oapps/oft/src/constants.rs +0 -5
  233. package/contracts/oapps/oft/src/default_oft_impl.rs +0 -152
  234. package/contracts/oapps/oft/src/errors.rs +0 -8
  235. package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +0 -23
  236. package/contracts/oapps/oft/src/interfaces/mod.rs +0 -3
  237. package/contracts/oapps/oft/src/tests/extensions/mod.rs +0 -11
  238. package/contracts/oapps/oft/src/tests/extensions/setup.rs +0 -903
  239. package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +0 -749
  240. package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +0 -432
  241. package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +0 -1078
  242. package/contracts/oapps/oft/src/types.rs +0 -38
  243. package/contracts/oapps/oft-std/integration-tests/utils.rs +0 -427
  244. package/contracts/oapps/oft-std/src/lib.rs +0 -16
  245. package/contracts/oapps/oft-std/src/oft.rs +0 -156
  246. package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
  247. package/contracts/workers/dvn/src/multisig.rs +0 -157
  248. package/sdk/dist/generated/oft_std.d.ts +0 -1544
  249. package/sdk/dist/generated/oft_std.js +0 -271
  250. package/sdk/test/index.test.ts +0 -375
  251. /package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/mod.rs +0 -0
  252. /package/contracts/oapps/{oft → oft-core}/src/codec/mod.rs +0 -0
  253. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_compose_msg_codec.rs +0 -0
  254. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_msg_codec.rs +0 -0
  255. /package/contracts/oapps/{oft → oft-core}/src/events.rs +0 -0
  256. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_compose_msg_codec.rs +0 -0
  257. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_version.rs +0 -0
  258. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_oft.rs +0 -0
  259. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_send.rs +0 -0
  260. /package/contracts/oapps/{oft → oft-core}/src/tests/test_send.rs +0 -0
  261. /package/contracts/oapps/{oft → oft-core}/src/tests/test_token.rs +0 -0
  262. /package/sdk/test/suites/{testUpgradeable.ts → dummyContractClient.ts} +0 -0
package/Cargo.lock CHANGED
@@ -332,14 +332,26 @@ version = "0.0.1"
332
332
  dependencies = [
333
333
  "assert_unordered",
334
334
  "common-macros",
335
+ "dvn",
336
+ "dvn-fee-lib",
337
+ "ed25519-dalek",
335
338
  "endpoint-v2",
336
339
  "executor",
340
+ "executor-fee-lib",
341
+ "executor-helper",
342
+ "k256",
337
343
  "message-lib-common",
338
344
  "oapp",
339
345
  "oapp-macros",
346
+ "price-feed",
347
+ "rand",
348
+ "sha3",
340
349
  "simple-message-lib",
341
350
  "soroban-sdk",
351
+ "treasury",
352
+ "uln302",
342
353
  "utils",
354
+ "worker",
343
355
  ]
344
356
 
345
357
  [[package]]
@@ -1187,31 +1199,32 @@ version = "0.0.1"
1187
1199
  name = "oft"
1188
1200
  version = "0.0.1"
1189
1201
  dependencies = [
1202
+ "cfg-if",
1190
1203
  "common-macros",
1191
1204
  "endpoint-v2",
1192
- "insta",
1193
1205
  "message-lib-common",
1194
1206
  "oapp",
1195
1207
  "oapp-macros",
1208
+ "oft-core",
1196
1209
  "simple-message-lib",
1197
1210
  "soroban-sdk",
1198
- "stellar-macros",
1199
- "stellar-tokens",
1200
1211
  "utils",
1201
1212
  ]
1202
1213
 
1203
1214
  [[package]]
1204
- name = "oft-std"
1215
+ name = "oft-core"
1205
1216
  version = "0.0.1"
1206
1217
  dependencies = [
1207
1218
  "common-macros",
1208
1219
  "endpoint-v2",
1220
+ "insta",
1209
1221
  "message-lib-common",
1210
1222
  "oapp",
1211
1223
  "oapp-macros",
1212
- "oft",
1213
1224
  "simple-message-lib",
1214
1225
  "soroban-sdk",
1226
+ "stellar-macros",
1227
+ "stellar-tokens",
1215
1228
  "utils",
1216
1229
  ]
1217
1230
 
@@ -2082,6 +2095,8 @@ name = "ts-bindings-gen"
2082
2095
  version = "0.0.1"
2083
2096
  dependencies = [
2084
2097
  "anyhow",
2098
+ "base64 0.22.1",
2099
+ "sha2 0.10.9",
2085
2100
  "soroban-spec-typescript",
2086
2101
  ]
2087
2102
 
package/Cargo.toml CHANGED
@@ -30,7 +30,10 @@ worker = { path = "contracts/workers/worker" }
30
30
  executor = { path = "contracts/workers/executor" }
31
31
  executor-helper = { path = "contracts/workers/executor-helper" }
32
32
  executor-fee-lib = { path = "contracts/workers/executor-fee-lib" }
33
- oft = { path = "contracts/oapps/oft" }
33
+ dvn = { path = "contracts/workers/dvn" }
34
+ dvn-fee-lib = { path = "contracts/workers/dvn-fee-lib" }
35
+ price-feed = { path = "contracts/workers/price-feed" }
36
+ oft-core = { path = "contracts/oapps/oft-core" }
34
37
  stellar-macros = { git = "https://github.com/OpenZeppelin/stellar-contracts.git", tag = "v0.5.1" }
35
38
  stellar-tokens = { git = "https://github.com/OpenZeppelin/stellar-contracts.git", tag = "v0.5.1" }
36
39
  stellar-contract-utils = { git = "https://github.com/OpenZeppelin/stellar-contracts.git", tag = "v0.5.1" }
@@ -0,0 +1,44 @@
1
+ # Stellar LayerZero Protocol - Error Code Specification
2
+
3
+ This document defines the error code allocation strategy for the Stellar LayerZero contracts.
4
+
5
+ ## Purpose
6
+
7
+ Each library has a unique error code range to:
8
+
9
+ - **Prevent collisions**: Avoid error code conflicts between different libraries
10
+ - **Enable traceability**: Quickly identify which library an error originated from based on its code
11
+ - **Simplify debugging**: Error codes are globally unique, making it easier to track and diagnose issues
12
+
13
+ ## Allocation Rules
14
+
15
+ - **Library allocation**: Each library is allocated a 100-unit block (e.g., 1000-1099, 1100-1199). Total errors in one library should not exceed 100.
16
+ - **Sub-range allocation**: Each error type within a library is allocated a 10-unit block. Example from `utils` (1000-1099):
17
+
18
+ - BufferReaderError: 1000-1009
19
+ - BufferWriterError: 1010-1019
20
+ - TtlConfigurableError: 1020-1029
21
+ - OwnableError: 1030-1039
22
+ - BytesExtError: 1040-1049
23
+ - UpgradeableError: 1050-1059
24
+ - MultisigError: 1060-1069
25
+
26
+ If an error type exceeds 10 errors (e.g., 12 errors), it extends into the next block but the following error type should start at the next 10-unit boundary (e.g., if errors are 1000-1011, next sub-range starts at 1020).
27
+
28
+ - **Auto-increment**: Within each error enum, values auto-increment from the starting value.
29
+
30
+ ## Error Code Ranges
31
+
32
+ | Range | Category | Library | Description |
33
+ | ----------- | --------------- | ------------------ | ------------------------------------------------------------ |
34
+ | 1 - 999 | Contract Errors | - | Application-specific contract errors (auto-increment from 1) |
35
+ | 1000 - 1099 | Protocol Lib | utils | `utils/src/errors.rs` |
36
+ | 1100 - 1199 | Protocol Lib | message-lib-common | `message-libs/message-lib-common/src/errors.rs` |
37
+ | 1200 - 1299 | Protocol Lib | worker | `workers/worker/src/errors.rs` |
38
+ | 1300 - 1999 | Protocol Lib | (reserved) | Future protocol libs |
39
+ | 2000 - 2099 | OApp Lib | oapp | `oapps/oapp/src/errors.rs` |
40
+ | 2100 - 2999 | OApp Lib | (reserved) | Future OApp libs |
41
+ | 3000 - 3099 | OFT Lib | oft-core | `oapps/oft-core/src/errors.rs` |
42
+ | 3100 - 3999 | OFT Lib | (reserved) | Future OFT libs |
43
+
44
+ ---
@@ -0,0 +1,113 @@
1
+ //! Authorization macros for Stellar contracts.
2
+ //!
3
+ //! This module provides macros for implementing authorization patterns:
4
+ //! - `#[ownable]` - Owner-based access control (external owner address)
5
+ //! - `#[multisig]` - Multisig-based access control (self-owning pattern)
6
+ //! - `#[only_auth]` - Authorization check attribute for functions
7
+
8
+ use crate::utils;
9
+ use proc_macro2::TokenStream;
10
+ use quote::{quote, ToTokens};
11
+ use syn::{parse_quote, ItemFn, ItemStruct};
12
+
13
+ // ============================================================================
14
+ // Ownable Macro Implementation
15
+ // ============================================================================
16
+
17
+ /// Generates the ownable implementation from the `#[ownable]` attribute macro.
18
+ ///
19
+ /// This macro implements both `Auth` and `Ownable` traits for the contract:
20
+ /// - `Auth::authorizer()` returns the stored owner address
21
+ /// - `Ownable` provides ownership management (transfer, renounce)
22
+ pub fn generate_ownable_impl(input: TokenStream) -> TokenStream {
23
+ let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
24
+ let name = &item_struct.ident;
25
+ let impl_mod = utils::impl_mod_ident(name, "ownable");
26
+
27
+ quote! {
28
+ #item_struct
29
+
30
+ use utils::{auth::Auth as _, ownable::{Ownable as _, OwnableInitializer as _}};
31
+
32
+ #[doc(hidden)]
33
+ mod #impl_mod {
34
+ use super::*;
35
+ use utils::{
36
+ auth::Auth,
37
+ errors::OwnableError,
38
+ option_ext::OptionExt as _,
39
+ ownable::{Ownable, OwnableInitializer},
40
+ };
41
+
42
+ impl OwnableInitializer for #name {}
43
+
44
+ #[common_macros::contract_impl]
45
+ impl Auth for #name {
46
+ fn authorizer(env: &soroban_sdk::Env) -> soroban_sdk::Address {
47
+ <Self as Ownable>::owner(env).unwrap_or_panic(env, OwnableError::OwnerNotSet)
48
+ }
49
+ }
50
+
51
+ #[common_macros::contract_impl(contracttrait)]
52
+ impl Ownable for #name {}
53
+ }
54
+ }
55
+ }
56
+
57
+ // ============================================================================
58
+ // Multisig Macro Implementation
59
+ // ============================================================================
60
+
61
+ /// Generates the multisig implementation from the `#[multisig]` attribute macro.
62
+ ///
63
+ /// This macro implements both `Auth` and `Multisig` traits for the contract:
64
+ /// - `Auth::authorizer()` returns the contract's own address (self-owning pattern)
65
+ /// - `Multisig` provides signature verification and signer management
66
+ pub fn generate_multisig_impl(input: TokenStream) -> TokenStream {
67
+ let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
68
+ let name = &item_struct.ident;
69
+ let impl_mod = utils::impl_mod_ident(name, "multisig");
70
+
71
+ quote! {
72
+ #item_struct
73
+
74
+ use utils::{auth::Auth as _, multisig::Multisig as _};
75
+
76
+ #[doc(hidden)]
77
+ mod #impl_mod {
78
+ use super::*;
79
+ use utils::{auth::Auth, multisig::Multisig};
80
+
81
+ #[common_macros::contract_impl]
82
+ impl Auth for #name {
83
+ fn authorizer(env: &soroban_sdk::Env) -> soroban_sdk::Address {
84
+ env.current_contract_address()
85
+ }
86
+ }
87
+
88
+ #[common_macros::contract_impl(contracttrait)]
89
+ impl Multisig for #name {}
90
+ }
91
+ }
92
+ }
93
+
94
+ // ============================================================================
95
+ // Only Auth Macro Implementation
96
+ // ============================================================================
97
+
98
+ /// Prepends an auth check to a method using the `Auth` trait.
99
+ ///
100
+ /// Works with any contract that implements the `Auth` trait, including both
101
+ /// `Ownable` and `Multisig` contracts.
102
+ pub fn prepend_only_auth_check(input: TokenStream) -> TokenStream {
103
+ let mut input_fn: ItemFn = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse function: {}", e));
104
+
105
+ let env_param = utils::expect_env_param(&input_fn.sig.inputs);
106
+
107
+ // Get a reference to env (handles both `Env` and `&Env` parameter types)
108
+ let env_ref = env_param.as_ref_tokens();
109
+
110
+ // Insert the auth check at the beginning of the function body
111
+ input_fn.block.stmts.insert(0, parse_quote!(utils::auth::require_auth::<Self>(#env_ref);));
112
+ input_fn.into_token_stream()
113
+ }
@@ -0,0 +1,84 @@
1
+ use crate::utils;
2
+ use proc_macro2::TokenStream;
3
+ use quote::quote;
4
+ use syn::{ImplItem, ItemImpl, ItemTrait, TraitItem, Visibility};
5
+
6
+ /// Generates a `#[soroban_sdk::contractimpl]` with automatic instance TTL extension.
7
+ pub fn contractimpl_with_ttl(attr: TokenStream, input: TokenStream) -> TokenStream {
8
+ let mut impl_block: ItemImpl = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse impl block: {}", e));
9
+
10
+ let is_trait_impl = impl_block.trait_.is_some();
11
+
12
+ for item in &mut impl_block.items {
13
+ let ImplItem::Fn(method) = item else { continue };
14
+
15
+ // For trait impls, process all methods; for inherent impls, only public methods
16
+ if !is_trait_impl && !matches!(method.vis, Visibility::Public(_)) {
17
+ continue;
18
+ }
19
+
20
+ // Skip the constructor as TTL config is typically not set during initialization
21
+ if method.sig.ident == "__constructor" {
22
+ continue;
23
+ }
24
+
25
+ // Skip methods without Env parameter
26
+ let Some(env_param) = utils::find_env_param(&method.sig.inputs) else { continue };
27
+
28
+ // Inject TTL extension at the start of the method body
29
+ method.block.stmts.insert(0, extend_instance_ttl_stmt(&env_param));
30
+ }
31
+
32
+ let contract_attr = if attr.is_empty() {
33
+ quote! { #[soroban_sdk::contractimpl]}
34
+ } else {
35
+ quote! { #[soroban_sdk::contractimpl(#attr)] }
36
+ };
37
+ quote! {
38
+ #contract_attr
39
+ #impl_block
40
+ }
41
+ }
42
+
43
+ /// Generates a `#[soroban_sdk::contracttrait]` with automatic instance TTL extension.
44
+ ///
45
+ /// This macro processes trait definitions and injects TTL extension logic into
46
+ /// default method implementations that have an `Env` parameter.
47
+ pub fn contracttrait_with_ttl(attr: TokenStream, input: TokenStream) -> TokenStream {
48
+ let mut trait_def: ItemTrait =
49
+ syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse trait definition: {}", e));
50
+
51
+ for item in &mut trait_def.items {
52
+ let TraitItem::Fn(method) = item else { continue };
53
+
54
+ // Only process methods with default implementations (have a body)
55
+ let Some(ref mut block) = method.default else { continue };
56
+
57
+ // Skip methods without Env parameter
58
+ let Some(env_param) = utils::find_env_param(&method.sig.inputs) else { continue };
59
+
60
+ // Inject TTL extension at the start of the method body
61
+ block.stmts.insert(0, extend_instance_ttl_stmt(&env_param));
62
+ }
63
+
64
+ let trait_attr = if attr.is_empty() {
65
+ quote! { #[soroban_sdk::contracttrait]}
66
+ } else {
67
+ quote! { #[soroban_sdk::contracttrait(#attr)] }
68
+ };
69
+ quote! {
70
+ #trait_attr
71
+ #trait_def
72
+ }
73
+ }
74
+
75
+ /// Generates a statement that extends instance TTL if configured.
76
+ fn extend_instance_ttl_stmt(env_param: &utils::EnvParam<'_>) -> syn::Stmt {
77
+ let env_ref = env_param.as_ref_tokens();
78
+ let env_ident = env_param.ident;
79
+ syn::parse_quote! {
80
+ if let Some(instance_ttl) = utils::ttl_configurable::TtlConfigStorage::instance(#env_ref) {
81
+ #env_ident.storage().instance().extend_ttl(instance_ttl.threshold, instance_ttl.extend_to);
82
+ }
83
+ }
84
+ }
@@ -3,26 +3,33 @@
3
3
  //! This crate provides foundational macros for Stellar contract development:
4
4
  //! - **Storage macros** - Strongly-typed contract storage API generation
5
5
  //! - **Error macros** - Contract error enum generation
6
- //! - **Ownable macros** - Owner-based access control implementation
6
+ //! - **Auth macros** - Authorization-based access control (ownable, multisig, only_auth)
7
7
  //! - **TTL macros** - Time-to-live configuration and automatic extension
8
+ //! - **Wrapper macros** - Convenient macro combinations for common patterns
8
9
  //!
9
10
  //! # Quick Links
10
11
  //! - [`storage`] - Storage enum to API macro
11
12
  //! - [`contract_error`] - Error enum generation macro
12
13
  //! - [`ownable`] - Ownable trait implementation macro
13
- //! - [`only_owner`] - Owner-only access control attribute macro
14
+ //! - [`multisig`] - Multisig trait implementation macro
15
+ //! - [`only_auth`] - Auth-based access control attribute macro
14
16
  //! - [`ttl_configurable`] - TTL configuration with freeze support
17
+ //! - [`ttl_extendable`] - Manual instance TTL extension
15
18
  //! - [`contract_impl`] - Contract impl with automatic instance TTL extension
19
+ //! - [`contract_trait`] - Contract trait with automatic instance TTL extension
16
20
  //! - [`upgradeable`] - Upgradeable trait implementation macro
21
+ //! - [`lz_contract`] - Wrapper macro combining common LayerZero contract attributes
17
22
  //!
18
- //!
23
+
19
24
  use proc_macro::TokenStream;
20
25
 
21
- mod contract_impl;
26
+ mod auth;
27
+ mod contract_ttl;
22
28
  mod error;
23
- mod ownable;
29
+ mod lz_contract;
24
30
  mod storage;
25
31
  mod ttl_configurable;
32
+ mod ttl_extendable;
26
33
  mod upgradeable;
27
34
  mod utils;
28
35
 
@@ -142,46 +149,74 @@ pub fn contract_error(attr: TokenStream, item: TokenStream) -> TokenStream {
142
149
  /// - `Ownable` trait impl - `owner(env)`, `transfer_ownership(env, new_owner)`, `renounce_ownership(env)`
143
150
  #[proc_macro_attribute]
144
151
  pub fn ownable(_attr: TokenStream, item: TokenStream) -> TokenStream {
145
- ownable::generate_ownable_impl(item.into()).into()
152
+ auth::generate_ownable_impl(item.into()).into()
146
153
  }
147
154
 
148
155
  // ============================================================================
149
- // Only Owner Macro
156
+ // Multisig Macro
150
157
  // ============================================================================
151
158
 
152
- /// Restricts function access to the contract owner only.
159
+ /// Generates multisig implementation with self-owning access control.
153
160
  ///
154
- /// This attribute macro injects an owner authentication check at the beginning
155
- /// of the function. The function will panic if called by a non-owner address.
161
+ /// Implements the `Multisig` trait and the `Auth` trait with self-owning pattern,
162
+ /// where the contract's own address is the authorizer. This allows multisig
163
+ /// quorum approval to serve as the authorizer for owner-protected operations
164
+ /// like TTL configuration and upgrades.
165
+ ///
166
+ /// # Example
167
+ /// ```ignore
168
+ /// #[multisig]
169
+ /// pub struct MyContract;
170
+ /// ```
171
+ ///
172
+ /// Generated code includes:
173
+ /// - `Auth` trait impl - `authorizer(env)` returns `env.current_contract_address()`
174
+ /// - `Multisig` trait impl - `set_signer(...)`, `set_threshold(...)`, `verify_signatures(...)`
175
+ #[proc_macro_attribute]
176
+ pub fn multisig(_attr: TokenStream, item: TokenStream) -> TokenStream {
177
+ auth::generate_multisig_impl(item.into()).into()
178
+ }
179
+
180
+ // ============================================================================
181
+ // Only Auth Macro
182
+ // ============================================================================
183
+
184
+ /// Restricts function access to the contract authorizer only.
185
+ ///
186
+ /// This attribute macro injects an auth check at the beginning of the function
187
+ /// using the `Auth` trait. The function will panic if called without authorization.
188
+ ///
189
+ /// Works with any contract that implements `Auth`, including both `Ownable` and
190
+ /// `Multisig` contracts.
156
191
  ///
157
192
  /// # Requirements
158
193
  /// - The function must have an `Env` parameter (by value or reference)
159
- /// - The containing contract must implement the `Ownable` trait (use `#[ownable]`)
194
+ /// - The containing contract must implement the `Auth` trait
160
195
  ///
161
196
  /// # Example
162
197
  /// ```ignore
163
- /// #[ownable]
198
+ /// #[ownable] // or implement Multisig
164
199
  /// pub struct MyContract;
165
200
  ///
166
201
  /// #[soroban_sdk::contractimpl]
167
202
  /// impl MyContract {
168
- /// #[only_owner]
169
- /// pub fn admin_action(env: Env) {
170
- /// // Only the owner can execute this
203
+ /// #[only_auth]
204
+ /// pub fn protected_action(env: Env) {
205
+ /// // Only the authorizer can execute this
171
206
  /// }
172
207
  /// }
173
208
  /// ```
174
209
  ///
175
210
  /// Generated code (conceptual):
176
211
  /// ```ignore
177
- /// pub fn admin_action(env: Env) {
178
- /// utils::ownable::require_owner_auth::<Self>(&env);
212
+ /// pub fn protected_action(env: Env) {
213
+ /// utils::auth::require_auth::<Self>(&env);
179
214
  /// // Original function body
180
215
  /// }
181
216
  /// ```
182
217
  #[proc_macro_attribute]
183
- pub fn only_owner(_attr: TokenStream, item: TokenStream) -> TokenStream {
184
- ownable::prepend_only_owner_check(item.into()).into()
218
+ pub fn only_auth(_attr: TokenStream, item: TokenStream) -> TokenStream {
219
+ auth::prepend_only_auth_check(item.into()).into()
185
220
  }
186
221
 
187
222
  // ============================================================================
@@ -191,14 +226,14 @@ pub fn only_owner(_attr: TokenStream, item: TokenStream) -> TokenStream {
191
226
  /// Generates TtlConfigurable trait implementation.
192
227
  ///
193
228
  /// This macro implements the `TtlConfigurable` trait for a contract struct,
194
- /// providing TTL configuration management with owner-only access control.
229
+ /// providing TTL configuration management with auth-based access control.
195
230
  ///
196
231
  /// # Requirements
197
- /// The contract must implement the `Ownable` trait (typically via `#[ownable]`).
232
+ /// The contract must implement the `Auth` trait (typically via `#[ownable]` or `Multisig`).
198
233
  ///
199
234
  /// # Example
200
235
  /// ```ignore
201
- /// #[ownable]
236
+ /// #[ownable] // or implement Multisig for self-owning contracts
202
237
  /// #[ttl_configurable]
203
238
  /// pub struct MyContract;
204
239
  ///
@@ -211,15 +246,39 @@ pub fn only_owner(_attr: TokenStream, item: TokenStream) -> TokenStream {
211
246
  /// ```
212
247
  ///
213
248
  /// Generated code includes:
214
- /// - `set_ttl_configs(env, instance, persistent)` - Set TTL configs (owner only)
249
+ /// - `set_ttl_configs(env, instance, persistent)` - Set TTL configs (auth required)
215
250
  /// - `ttl_configs(env)` - Get current TTL configs (instance, persistent)
216
- /// - `freeze_ttl_configs(env)` - Permanently freeze TTL configs (owner only)
251
+ /// - `freeze_ttl_configs(env)` - Permanently freeze TTL configs (auth required)
217
252
  /// - `is_ttl_configs_frozen(env)` - Check if TTL configs are frozen
218
253
  #[proc_macro_attribute]
219
254
  pub fn ttl_configurable(_attr: TokenStream, item: TokenStream) -> TokenStream {
220
255
  ttl_configurable::generate_ttl_configurable_impl(item.into()).into()
221
256
  }
222
257
 
258
+ // ============================================================================
259
+ // TTL Extendable Macro
260
+ // ============================================================================
261
+
262
+ /// Generates TtlExtendable trait implementation for manual instance TTL extension.
263
+ ///
264
+ /// This macro implements the `TtlExtendable` trait, providing a public
265
+ /// `extend_instance_ttl` function that allows external callers to extend
266
+ /// the contract's instance storage TTL.
267
+ ///
268
+ /// # Example
269
+ /// ```ignore
270
+ /// #[contract]
271
+ /// #[ttl_extendable]
272
+ /// pub struct MyContract;
273
+ /// ```
274
+ ///
275
+ /// Generated code includes:
276
+ /// - `extend_instance_ttl(env, threshold, extend_to)` - Extends instance TTL
277
+ #[proc_macro_attribute]
278
+ pub fn ttl_extendable(_attr: TokenStream, item: TokenStream) -> TokenStream {
279
+ ttl_extendable::generate_ttl_extendable_impl(item.into()).into()
280
+ }
281
+
223
282
  // ============================================================================
224
283
  // Contract Impl Macro
225
284
  // ============================================================================
@@ -267,24 +326,77 @@ pub fn ttl_configurable(_attr: TokenStream, item: TokenStream) -> TokenStream {
267
326
  /// ```
268
327
  #[proc_macro_attribute]
269
328
  pub fn contract_impl(attr: TokenStream, item: TokenStream) -> TokenStream {
270
- contract_impl::contract_impl(attr.into(), item.into()).into()
329
+ contract_ttl::contractimpl_with_ttl(attr.into(), item.into()).into()
330
+ }
331
+
332
+ // ============================================================================
333
+ // Contract Trait Macro
334
+ // ============================================================================
335
+
336
+ /// Wraps `#[soroban_sdk::contracttrait]` with automatic instance TTL extension.
337
+ ///
338
+ /// This macro applies `#[soroban_sdk::contracttrait]` and injects TTL extension logic
339
+ /// at the beginning of each default trait method to keep the contract instance alive.
340
+ ///
341
+ /// # Requirements
342
+ /// - The implementing contract must have `#[ttl_configurable]` applied
343
+ /// - Methods must have an `Env` parameter to receive TTL extension
344
+ /// - Only methods with default implementations are processed
345
+ ///
346
+ /// # Behavior
347
+ /// - All default methods with an `Env` parameter receive TTL extension
348
+ /// - Methods without a body (abstract methods) are not modified
349
+ /// - Methods without an `Env` parameter are skipped
350
+ ///
351
+ /// # Example
352
+ /// ```ignore
353
+ /// #[contract_trait]
354
+ /// pub trait MyTrait {
355
+ /// /// This method will have TTL extension injected
356
+ /// fn my_method(env: &Env) {
357
+ /// // TTL extension is automatically injected here
358
+ /// // ... your code
359
+ /// }
360
+ ///
361
+ /// /// Abstract methods are not modified
362
+ /// fn abstract_method(env: &Env) -> u32;
363
+ /// }
364
+ /// ```
365
+ ///
366
+ /// Generated code (conceptual):
367
+ /// ```ignore
368
+ /// #[soroban_sdk::contracttrait]
369
+ /// pub trait MyTrait {
370
+ /// fn my_method(env: &Env) {
371
+ /// if let Some(ttl) = utils::ttl_configurable::TtlConfigStorage::instance(env) {
372
+ /// env.storage().instance().extend_ttl(ttl.threshold, ttl.extend_to);
373
+ /// }
374
+ /// // ... your code
375
+ /// }
376
+ ///
377
+ /// fn abstract_method(env: &Env) -> u32;
378
+ /// }
379
+ /// ```
380
+ #[proc_macro_attribute]
381
+ pub fn contract_trait(attr: TokenStream, item: TokenStream) -> TokenStream {
382
+ contract_ttl::contracttrait_with_ttl(attr.into(), item.into()).into()
271
383
  }
272
384
 
273
385
  // ============================================================================
274
386
  // Upgradeable Macro
275
387
  // ============================================================================
276
388
 
277
- /// Generates upgradeable implementation with owner-based access control.
389
+ /// Generates upgradeable implementation with auth-based access control.
278
390
  ///
279
391
  /// Implements the `Upgradeable` trait for contract upgrade and migration functionality.
280
392
  ///
281
393
  /// # Requirements
282
- /// - The contract must have `#[ownable]` applied for owner management
394
+ /// - The contract must implement the `Auth` trait (via `#[ownable]` or `Multisig`)
283
395
  /// - The contract must implement `UpgradeableInternal` trait with migration logic
284
396
  ///
285
397
  /// # Example
286
398
  /// ```ignore
287
- /// #[ownable]
399
+ /// #[ownable] // or implement Multisig for self-owning contracts
288
400
  /// #[upgradeable]
289
401
  /// pub struct MyContract;
290
402
  ///
@@ -298,10 +410,49 @@ pub fn contract_impl(attr: TokenStream, item: TokenStream) -> TokenStream {
298
410
  /// ```
299
411
  ///
300
412
  /// Generated code includes:
301
- /// - `upgrade(env, new_wasm_hash)` - Upgrades the contract WASM (owner only)
302
- /// - `migrate(env, migration_data)` - Runs migration after upgrade (owner only)
413
+ /// - `upgrade(env, new_wasm_hash)` - Upgrades the contract WASM (auth required)
414
+ /// - `migrate(env, migration_data)` - Runs migration after upgrade (auth required)
303
415
  /// - `contractmeta!` with `binver` set to the Cargo package version (if not 0.0.0)
304
416
  #[proc_macro_attribute]
305
417
  pub fn upgradeable(_attr: TokenStream, item: TokenStream) -> TokenStream {
306
418
  upgradeable::generate_upgradeable_impl(item.into()).into()
307
419
  }
420
+
421
+ // ============================================================================
422
+ // LZ Contract Wrapper Macro
423
+ // ============================================================================
424
+
425
+ /// Wrapper macro that combines common LayerZero contract attributes.
426
+ ///
427
+ /// This macro simplifies contract declarations by combining multiple commonly
428
+ /// used macros into a single attribute.
429
+ ///
430
+ /// # Default (no options)
431
+ /// `#[lz_contract]` generates:
432
+ /// - `#[contract]` - Soroban contract
433
+ /// - `#[ttl_configurable]` - TTL configuration with auth
434
+ /// - `#[ttl_extendable]` - Manual TTL extension
435
+ /// - `#[ownable]` - Single-owner access control
436
+ ///
437
+ /// # Options
438
+ /// - `upgradeable` - Adds `#[upgradeable]` for contract upgrade support
439
+ /// - `multisig` - Uses `#[multisig]` instead of `#[ownable]`
440
+ ///
441
+ /// # Examples
442
+ /// ```ignore
443
+ /// // Basic contract with ownable auth
444
+ /// #[lz_contract]
445
+ /// pub struct EndpointV2;
446
+ ///
447
+ /// // Contract with upgrade support
448
+ /// #[lz_contract(upgradeable)]
449
+ /// pub struct DVNFeeLib;
450
+ ///
451
+ /// // Contract with multisig auth and upgrade support
452
+ /// #[lz_contract(multisig, upgradeable)]
453
+ /// pub struct DVN;
454
+ /// ```
455
+ #[proc_macro_attribute]
456
+ pub fn lz_contract(attr: TokenStream, item: TokenStream) -> TokenStream {
457
+ lz_contract::generate_lz_contract(attr.into(), item.into()).into()
458
+ }