create-dubhe 1.2.0-pre.98 → 2.0.0

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 (361) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/package.json +16 -16
  4. package/templates/101/sui-template/docker-compose.testnet.yml +73 -0
  5. package/templates/101/sui-template/packages/client/src/app/page.tsx +545 -41
  6. package/templates/101/sui-template/packages/client/src/app/providers.tsx +12 -4
  7. package/templates/101/sui-template/packages/contracts/Pub.localnet.toml +4 -4
  8. package/templates/101/sui-template/packages/contracts/counter.lock.json +20 -0
  9. package/templates/101/sui-template/packages/contracts/deployment.ts +8 -3
  10. package/templates/101/sui-template/packages/contracts/dubhe.config.json +59 -13
  11. package/templates/101/sui-template/packages/contracts/dubhe.config.ts +1 -4
  12. package/templates/101/sui-template/packages/contracts/metadata.json +1015 -68
  13. package/templates/101/sui-template/packages/contracts/package.json +7 -4
  14. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/dapp_key.move +45 -31
  15. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/error.move +8 -0
  16. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/genesis.move +30 -13
  17. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/init_test.move +19 -14
  18. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2.move +198 -0
  19. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2withkey.move +90 -0
  20. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/value.move +30 -20
  21. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
  22. package/templates/101/sui-template/packages/contracts/src/counter/sources/scripts/deploy_hook.move +6 -11
  23. package/templates/101/sui-template/packages/contracts/src/counter/sources/systems/counter.move +23 -11
  24. package/templates/101/sui-template/packages/contracts/src/counter/sources/tests/counter.move +15 -14
  25. package/templates/101/sui-template/packages/contracts/src/dubhe/Move.lock +33 -30
  26. package/templates/101/sui-template/packages/contracts/src/dubhe/Move.toml +8 -3
  27. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/dapp_key.move +45 -31
  28. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/error.move +170 -0
  29. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/genesis.move +16 -13
  30. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/init_test.move +8 -14
  31. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/account_key.move +1 -3
  32. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/dapp_service.move +1776 -137
  33. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/data_key.move +1 -20
  34. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/events.move +864 -25
  35. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/scripts/deploy_hook.move +15 -16
  36. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/scripts/migrate.move +0 -3
  37. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/address_system.move +25 -17
  38. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/dapp_system.move +2802 -343
  39. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/utils.move +1 -1
  40. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/address.move +173 -55
  41. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/dapp_test.move +769 -0
  42. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/fee_test.move +2965 -0
  43. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/integration_test.move +303 -0
  44. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/listing_test.move +1422 -0
  45. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/scene_session_test.move +269 -0
  46. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/session_test.move +624 -0
  47. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/storage_test.move +700 -0
  48. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/typed_object_test.move +177 -0
  49. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/typed_scene_test.move +452 -0
  50. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/user_storage_test.move +160 -0
  51. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/utils/math.move +4 -3
  52. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/utils/type_info.move +2 -2
  53. package/templates/contract/sui-template/dubhe.config.ts +0 -1
  54. package/templates/contract/sui-template/package.json +3 -3
  55. package/templates/contract/sui-template/src/dubhe/Move.lock +33 -30
  56. package/templates/contract/sui-template/src/dubhe/Move.toml +8 -3
  57. package/templates/contract/sui-template/src/dubhe/sources/codegen/dapp_key.move +45 -31
  58. package/templates/contract/sui-template/src/dubhe/sources/codegen/error.move +170 -0
  59. package/templates/contract/sui-template/src/dubhe/sources/codegen/genesis.move +16 -13
  60. package/templates/contract/sui-template/src/dubhe/sources/codegen/init_test.move +8 -14
  61. package/templates/contract/sui-template/src/dubhe/sources/core/account_key.move +1 -3
  62. package/templates/contract/sui-template/src/dubhe/sources/core/dapp_service.move +1776 -137
  63. package/templates/contract/sui-template/src/dubhe/sources/core/data_key.move +1 -20
  64. package/templates/contract/sui-template/src/dubhe/sources/core/events.move +864 -25
  65. package/templates/contract/sui-template/src/dubhe/sources/scripts/deploy_hook.move +15 -16
  66. package/templates/contract/sui-template/src/dubhe/sources/scripts/migrate.move +0 -3
  67. package/templates/contract/sui-template/src/dubhe/sources/systems/address_system.move +25 -17
  68. package/templates/contract/sui-template/src/dubhe/sources/systems/dapp_system.move +2802 -343
  69. package/templates/contract/sui-template/src/dubhe/sources/systems/utils.move +1 -1
  70. package/templates/contract/sui-template/src/dubhe/sources/tests/address.move +173 -55
  71. package/templates/contract/sui-template/src/dubhe/sources/tests/dapp_test.move +769 -0
  72. package/templates/contract/sui-template/src/dubhe/sources/tests/fee_test.move +2965 -0
  73. package/templates/contract/sui-template/src/dubhe/sources/tests/integration_test.move +303 -0
  74. package/templates/contract/sui-template/src/dubhe/sources/tests/listing_test.move +1422 -0
  75. package/templates/contract/sui-template/src/dubhe/sources/tests/scene_session_test.move +269 -0
  76. package/templates/contract/sui-template/src/dubhe/sources/tests/session_test.move +624 -0
  77. package/templates/contract/sui-template/src/dubhe/sources/tests/storage_test.move +700 -0
  78. package/templates/contract/sui-template/src/dubhe/sources/tests/typed_object_test.move +177 -0
  79. package/templates/contract/sui-template/src/dubhe/sources/tests/typed_scene_test.move +452 -0
  80. package/templates/contract/sui-template/src/dubhe/sources/tests/user_storage_test.move +160 -0
  81. package/templates/contract/sui-template/src/dubhe/sources/utils/math.move +4 -3
  82. package/templates/contract/sui-template/src/dubhe/sources/utils/type_info.move +2 -2
  83. package/templates/contract/sui-template/src/template/Move.toml +12 -0
  84. package/templates/contract/sui-template/src/template/sources/codegen/dapp_key.move +47 -0
  85. package/templates/contract/sui-template/src/template/sources/codegen/genesis.move +34 -0
  86. package/templates/contract/sui-template/src/template/sources/codegen/init_test.move +23 -0
  87. package/templates/contract/sui-template/src/template/sources/codegen/user_storage_init.move +27 -0
  88. package/templates/contract/sui-template/src/template/sources/scripts/deploy_hook.move +13 -0
  89. package/templates/contract/sui-template/src/template/sources/scripts/migrate.move +7 -0
  90. package/templates/nextjs/sui-card-duel/.gitignore_ +51 -0
  91. package/templates/nextjs/sui-card-duel/README.md +213 -0
  92. package/templates/nextjs/sui-card-duel/docker-compose.yml +34 -0
  93. package/templates/nextjs/sui-card-duel/mprocs.yaml +17 -0
  94. package/templates/nextjs/sui-card-duel/package.json +43 -0
  95. package/templates/nextjs/sui-card-duel/packages/client/.gitignore_ +48 -0
  96. package/templates/nextjs/sui-card-duel/packages/client/.prettierignore +1 -0
  97. package/templates/nextjs/sui-card-duel/packages/client/.prettierrc.json +8 -0
  98. package/templates/nextjs/sui-card-duel/packages/client/eslint.config.mjs +22 -0
  99. package/templates/nextjs/sui-card-duel/packages/client/next.config.mjs +8 -0
  100. package/templates/nextjs/sui-card-duel/packages/client/package.json +47 -0
  101. package/templates/nextjs/sui-card-duel/packages/client/postcss.config.mjs +8 -0
  102. package/templates/nextjs/sui-card-duel/packages/client/src/app/admin/ArenaPanel.tsx +307 -0
  103. package/templates/nextjs/sui-card-duel/packages/client/src/app/admin/page.tsx +622 -0
  104. package/templates/nextjs/sui-card-duel/packages/client/src/app/brawl/[id]/page.tsx +559 -0
  105. package/templates/nextjs/sui-card-duel/packages/client/src/app/collection/page.tsx +202 -0
  106. package/templates/nextjs/sui-card-duel/packages/client/src/app/components/CardView.tsx +66 -0
  107. package/templates/nextjs/sui-card-duel/packages/client/src/app/components/GameShell.tsx +294 -0
  108. package/templates/nextjs/sui-card-duel/packages/client/src/app/components/icons.tsx +101 -0
  109. package/templates/nextjs/sui-card-duel/packages/client/src/app/duel/[id]/page.tsx +477 -0
  110. package/templates/nextjs/sui-card-duel/packages/client/src/app/favicon.ico +0 -0
  111. package/templates/nextjs/sui-card-duel/packages/client/src/app/globals.css +85 -0
  112. package/templates/nextjs/sui-card-duel/packages/client/src/app/hooks/useGame.ts +313 -0
  113. package/templates/nextjs/sui-card-duel/packages/client/src/app/layout.tsx +24 -0
  114. package/templates/nextjs/sui-card-duel/packages/client/src/app/leaderboard/page.tsx +123 -0
  115. package/templates/nextjs/sui-card-duel/packages/client/src/app/lib/game.ts +77 -0
  116. package/templates/nextjs/sui-card-duel/packages/client/src/app/lib/scenes.ts +226 -0
  117. package/templates/nextjs/sui-card-duel/packages/client/src/app/market/page.tsx +418 -0
  118. package/templates/nextjs/sui-card-duel/packages/client/src/app/page.tsx +427 -0
  119. package/templates/nextjs/sui-card-duel/packages/client/src/app/providers.tsx +69 -0
  120. package/templates/nextjs/sui-card-duel/packages/client/tailwind.config.ts +21 -0
  121. package/templates/nextjs/sui-card-duel/packages/client/tsconfig.json +30 -0
  122. package/templates/nextjs/sui-card-duel/packages/contracts/.gitignore_ +51 -0
  123. package/templates/nextjs/sui-card-duel/packages/contracts/.prettierignore +1 -0
  124. package/templates/nextjs/sui-card-duel/packages/contracts/.prettierrc.json +8 -0
  125. package/templates/nextjs/sui-card-duel/packages/contracts/Dockerfile +5 -0
  126. package/templates/nextjs/sui-card-duel/packages/contracts/Pub.localnet.toml +13 -0
  127. package/templates/nextjs/sui-card-duel/packages/contracts/card_duel.lock.json +66 -0
  128. package/templates/nextjs/sui-card-duel/packages/contracts/docker-compose.yml +34 -0
  129. package/templates/nextjs/sui-card-duel/packages/contracts/dubhe.config.ts +150 -0
  130. package/templates/nextjs/sui-card-duel/packages/contracts/logs/combined.log +31383 -0
  131. package/templates/nextjs/sui-card-duel/packages/contracts/package.json +49 -0
  132. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/config.ts +17 -0
  133. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-brawl.ts +270 -0
  134. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-duel.ts +272 -0
  135. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-lobby.ts +177 -0
  136. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-market.ts +219 -0
  137. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-session.ts +342 -0
  138. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/query-dapp-revenue.ts +95 -0
  139. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/seed.ts +92 -0
  140. package/templates/nextjs/sui-card-duel/packages/contracts/scripts/withdraw-dapp-revenue.ts +56 -0
  141. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/Move.toml +15 -0
  142. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/dapp_key.move +46 -0
  143. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/card_kind.move +47 -0
  144. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/match_state.move +37 -0
  145. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/rarity.move +37 -0
  146. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/error.move +126 -0
  147. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/genesis.move +33 -0
  148. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/init_test.move +23 -0
  149. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/objects/arena.move +137 -0
  150. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/permits/brawl_permit.move +125 -0
  151. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/permits/duel_permit.move +125 -0
  152. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/battle_state.move +255 -0
  153. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/card.move +282 -0
  154. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/deck.move +64 -0
  155. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/game_config.move +267 -0
  156. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/gold.move +205 -0
  157. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/profile.move +255 -0
  158. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/scenes/brawl.move +313 -0
  159. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/scenes/duel.move +313 -0
  160. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/user_storage_init.move +26 -0
  161. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/scripts/deploy_hook.move +32 -0
  162. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/scripts/migrate.move +7 -0
  163. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/arena_system.move +57 -0
  164. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/brawl_system.move +559 -0
  165. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/card_system.move +146 -0
  166. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/duel_system.move +515 -0
  167. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/market_system.move +115 -0
  168. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/player_system.move +37 -0
  169. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/brawl_tests.move +385 -0
  170. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/duel_tests.move +656 -0
  171. package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/test_helpers.move +31 -0
  172. package/templates/nextjs/sui-card-duel/packages/contracts/sui-indexer-schema.graphql +5973 -0
  173. package/templates/nextjs/sui-card-duel/pnpm-workspace.yaml +2 -0
  174. package/templates/nextjs/sui-farm/.gitignore_ +51 -0
  175. package/templates/nextjs/sui-farm/README.md +15 -0
  176. package/templates/nextjs/sui-farm/UPGRADE_NOTES.md +97 -0
  177. package/templates/nextjs/sui-farm/docker-compose.yml +34 -0
  178. package/templates/nextjs/sui-farm/mprocs.yaml +17 -0
  179. package/templates/nextjs/sui-farm/package.json +43 -0
  180. package/templates/nextjs/sui-farm/packages/client/.gitignore_ +48 -0
  181. package/templates/nextjs/sui-farm/packages/client/.prettierignore +1 -0
  182. package/templates/nextjs/sui-farm/packages/client/.prettierrc.json +8 -0
  183. package/templates/nextjs/sui-farm/packages/client/eslint.config.mjs +22 -0
  184. package/templates/nextjs/sui-farm/packages/client/next.config.mjs +8 -0
  185. package/templates/nextjs/sui-farm/packages/client/package.json +47 -0
  186. package/templates/nextjs/sui-farm/packages/client/postcss.config.mjs +8 -0
  187. package/templates/nextjs/sui-farm/packages/client/src/app/admin/page.tsx +618 -0
  188. package/templates/nextjs/sui-farm/packages/client/src/app/components/FarmLand.tsx +526 -0
  189. package/templates/nextjs/sui-farm/packages/client/src/app/components/FarmPlotCard.tsx +215 -0
  190. package/templates/nextjs/sui-farm/packages/client/src/app/components/PetAvatar.tsx +868 -0
  191. package/templates/nextjs/sui-farm/packages/client/src/app/components/PetPanel.tsx +1360 -0
  192. package/templates/nextjs/sui-farm/packages/client/src/app/components/PlantModal.tsx +147 -0
  193. package/templates/nextjs/sui-farm/packages/client/src/app/components/ProxyCard.tsx +684 -0
  194. package/templates/nextjs/sui-farm/packages/client/src/app/components/RanchLand.tsx +822 -0
  195. package/templates/nextjs/sui-farm/packages/client/src/app/components/ResourceHUD.tsx +125 -0
  196. package/templates/nextjs/sui-farm/packages/client/src/app/components/ShopPanel.tsx +232 -0
  197. package/templates/nextjs/sui-farm/packages/client/src/app/components/icons/GameIcons.tsx +574 -0
  198. package/templates/nextjs/sui-farm/packages/client/src/app/favicon.ico +0 -0
  199. package/templates/nextjs/sui-farm/packages/client/src/app/globals.css +423 -0
  200. package/templates/nextjs/sui-farm/packages/client/src/app/hooks/useWorldPermitId.ts +66 -0
  201. package/templates/nextjs/sui-farm/packages/client/src/app/layout.tsx +23 -0
  202. package/templates/nextjs/sui-farm/packages/client/src/app/leaderboard/page.tsx +185 -0
  203. package/templates/nextjs/sui-farm/packages/client/src/app/lib/crops.ts +97 -0
  204. package/templates/nextjs/sui-farm/packages/client/src/app/market/page.tsx +763 -0
  205. package/templates/nextjs/sui-farm/packages/client/src/app/page.tsx +1173 -0
  206. package/templates/nextjs/sui-farm/packages/client/src/app/providers.tsx +69 -0
  207. package/templates/nextjs/sui-farm/packages/client/src/app/state/index.tsx +5 -0
  208. package/templates/nextjs/sui-farm/packages/client/tailwind.config.ts +25 -0
  209. package/templates/nextjs/sui-farm/packages/client/tsconfig.json +30 -0
  210. package/templates/nextjs/sui-farm/packages/contracts/.gitignore_ +51 -0
  211. package/templates/nextjs/sui-farm/packages/contracts/.prettierignore +1 -0
  212. package/templates/nextjs/sui-farm/packages/contracts/.prettierrc.json +8 -0
  213. package/templates/nextjs/sui-farm/packages/contracts/Dockerfile +5 -0
  214. package/templates/nextjs/sui-farm/packages/contracts/Pub.localnet.toml +13 -0
  215. package/templates/nextjs/sui-farm/packages/contracts/counter.lock.json +14 -0
  216. package/templates/nextjs/sui-farm/packages/contracts/docker-compose.yml +34 -0
  217. package/templates/nextjs/sui-farm/packages/contracts/dubhe.config.ts +178 -0
  218. package/templates/nextjs/sui-farm/packages/contracts/harvest.lock.json +120 -0
  219. package/templates/nextjs/sui-farm/packages/contracts/package.json +48 -0
  220. package/templates/nextjs/sui-farm/packages/contracts/scripts/config.ts +17 -0
  221. package/templates/nextjs/sui-farm/packages/contracts/scripts/query-dapp-revenue.ts +95 -0
  222. package/templates/nextjs/sui-farm/packages/contracts/scripts/read-permit.ts +72 -0
  223. package/templates/nextjs/sui-farm/packages/contracts/scripts/seed.ts +85 -0
  224. package/templates/nextjs/sui-farm/packages/contracts/scripts/withdraw-dapp-revenue.ts +56 -0
  225. package/templates/nextjs/sui-farm/packages/contracts/src/counter/Move.toml +14 -0
  226. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/dapp_key.move +31 -0
  227. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/error.move +10 -0
  228. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/genesis.move +33 -0
  229. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/init_test.move +23 -0
  230. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/resources/counter1.move +64 -0
  231. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/resources/counter2.move +70 -0
  232. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
  233. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/scripts/deploy_hook.move +8 -0
  234. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/scripts/migrate.move +8 -0
  235. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/systems/counter.move +13 -0
  236. package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/tests/counter.move +28 -0
  237. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/Move.toml +14 -0
  238. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/dapp_key.move +46 -0
  239. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/crop_type.move +47 -0
  240. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/egg_type.move +42 -0
  241. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/pet_rarity.move +37 -0
  242. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/pet_species.move +52 -0
  243. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/error.move +110 -0
  244. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/genesis.move +33 -0
  245. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/init_test.move +23 -0
  246. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/permits/world.move +125 -0
  247. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/carrot.move +136 -0
  248. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/carrot_seed.move +80 -0
  249. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/common_egg.move +136 -0
  250. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/corn.move +136 -0
  251. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/corn_seed.move +80 -0
  252. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/crow_charges.move +162 -0
  253. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/crow_damage.move +207 -0
  254. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/farm_plot.move +261 -0
  255. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/gold.move +80 -0
  256. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet.move +467 -0
  257. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_config.move +372 -0
  258. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_hatch.move +162 -0
  259. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_slot_index.move +83 -0
  260. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_slots.move +64 -0
  261. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/profile.move +162 -0
  262. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pumpkin.move +136 -0
  263. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pumpkin_seed.move +80 -0
  264. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/rare_egg.move +136 -0
  265. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/scarecrow.move +64 -0
  266. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/season_config.move +197 -0
  267. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/season_stats.move +64 -0
  268. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/seasonal_egg.move +136 -0
  269. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/shop_config.move +267 -0
  270. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/trophy.move +245 -0
  271. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/wheat.move +136 -0
  272. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/wheat_seed.move +80 -0
  273. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/world_permit_id.move +64 -0
  274. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/user_storage_init.move +26 -0
  275. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/scripts/deploy_hook.move +45 -0
  276. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/scripts/migrate.move +7 -0
  277. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/crow_system.move +96 -0
  278. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/farm_system.move +182 -0
  279. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/market_system.move +172 -0
  280. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/pet_system.move +495 -0
  281. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/season_system.move +70 -0
  282. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/shop_system.move +112 -0
  283. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/world_system.move +34 -0
  284. package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/tests/farm_tests.move +1192 -0
  285. package/templates/nextjs/sui-farm/pnpm-workspace.yaml +2 -0
  286. package/templates/nextjs/sui-template/packages/client/src/app/components/ProxyCard.tsx +683 -0
  287. package/templates/nextjs/sui-template/packages/client/src/app/page.tsx +510 -5
  288. package/templates/nextjs/sui-template/packages/client/src/app/providers.tsx +13 -5
  289. package/templates/nextjs/sui-template/packages/contracts/Pub.localnet.toml +4 -4
  290. package/templates/nextjs/sui-template/packages/contracts/counter.lock.json +14 -0
  291. package/templates/nextjs/sui-template/packages/contracts/deployment.ts +8 -3
  292. package/templates/nextjs/sui-template/packages/contracts/dubhe.config.json +9 -9
  293. package/templates/nextjs/sui-template/packages/contracts/dubhe.config.ts +0 -4
  294. package/templates/nextjs/sui-template/packages/contracts/metadata.json +180 -124
  295. package/templates/nextjs/sui-template/packages/contracts/package.json +8 -4
  296. package/templates/nextjs/sui-template/packages/contracts/src/counter/Move.toml +4 -0
  297. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/dapp_key.move +45 -31
  298. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/error.move +10 -0
  299. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/genesis.move +30 -13
  300. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/init_test.move +19 -14
  301. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter1.move +30 -20
  302. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2.move +35 -24
  303. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
  304. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/scripts/deploy_hook.move +6 -10
  305. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/systems/counter.move +7 -20
  306. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/tests/counter.move +14 -27
  307. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/Move.lock +33 -30
  308. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/Move.toml +8 -3
  309. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/dapp_key.move +45 -31
  310. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/error.move +170 -0
  311. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/genesis.move +16 -13
  312. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/init_test.move +8 -14
  313. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/account_key.move +1 -3
  314. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/dapp_service.move +1776 -137
  315. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/data_key.move +1 -20
  316. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/events.move +864 -25
  317. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/scripts/deploy_hook.move +15 -16
  318. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/scripts/migrate.move +0 -3
  319. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/address_system.move +25 -17
  320. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/dapp_system.move +2802 -343
  321. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/utils.move +1 -1
  322. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/address.move +173 -55
  323. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/dapp_test.move +769 -0
  324. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/fee_test.move +2965 -0
  325. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/integration_test.move +303 -0
  326. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/listing_test.move +1422 -0
  327. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/scene_session_test.move +269 -0
  328. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/session_test.move +624 -0
  329. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/storage_test.move +700 -0
  330. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/typed_object_test.move +177 -0
  331. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/typed_scene_test.move +452 -0
  332. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/user_storage_test.move +160 -0
  333. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/utils/math.move +4 -3
  334. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/utils/type_info.move +2 -2
  335. package/templates/101/sui-template/packages/contracts/src/counter/Move.lock +0 -41
  336. package/templates/101/sui-template/packages/contracts/src/counter/Published.toml +0 -9
  337. package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/errors.move +0 -12
  338. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/errors.move +0 -140
  339. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
  340. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
  341. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
  342. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
  343. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/dapp_store.move +0 -29
  344. package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/session_system.move +0 -44
  345. package/templates/contract/sui-template/src/dubhe/sources/codegen/errors.move +0 -140
  346. package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
  347. package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
  348. package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
  349. package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
  350. package/templates/contract/sui-template/src/dubhe/sources/core/dapp_store.move +0 -29
  351. package/templates/contract/sui-template/src/dubhe/sources/systems/session_system.move +0 -44
  352. package/templates/nextjs/sui-template/packages/contracts/src/counter/Move.lock +0 -47
  353. package/templates/nextjs/sui-template/packages/contracts/src/counter/Published.toml +0 -9
  354. package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/errors.move +0 -12
  355. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/errors.move +0 -140
  356. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
  357. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
  358. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
  359. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
  360. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/dapp_store.move +0 -29
  361. package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/session_system.move +0 -44
@@ -3,41 +3,880 @@ module dubhe::dubhe_events;
3
3
  use sui::event;
4
4
  use std::ascii::String;
5
5
 
6
+ // ─── Storage events ───────────────────────────────────────────────────────────
6
7
 
7
8
  public struct Dubhe_Store_SetRecord has copy, drop {
8
- dapp_key: String,
9
- account: String,
10
- key: vector<vector<u8>>,
11
- value: vector<vector<u8>>
9
+ dapp_key: String,
10
+ account: String,
11
+ key: vector<vector<u8>>,
12
+ value: vector<vector<u8>>,
12
13
  }
13
14
 
14
- public fun new_store_set_record(dapp_key: String, account: String, key: vector<vector<u8>>, value: vector<vector<u8>>): Dubhe_Store_SetRecord {
15
- Dubhe_Store_SetRecord {
16
- dapp_key,
17
- account,
18
- key,
19
- value
20
- }
15
+ public(package) fun new_store_set_record(
16
+ dapp_key: String,
17
+ account: String,
18
+ key: vector<vector<u8>>,
19
+ value: vector<vector<u8>>,
20
+ ): Dubhe_Store_SetRecord {
21
+ Dubhe_Store_SetRecord { dapp_key, account, key, value }
21
22
  }
22
23
 
23
- public fun emit_store_set_record(dapp_key: String, account: String, key: vector<vector<u8>>, value: vector<vector<u8>>) {
24
- event::emit(new_store_set_record(dapp_key, account, key, value));
24
+ /// Only dapp_service (same package) may emit storage events.
25
+ /// Making this package-internal prevents any external module from forging
26
+ /// arbitrary SetRecord events to poison the off-chain indexer.
27
+ public(package) fun emit_store_set_record(
28
+ dapp_key: String,
29
+ account: String,
30
+ key: vector<vector<u8>>,
31
+ value: vector<vector<u8>>,
32
+ ) {
33
+ event::emit(new_store_set_record(dapp_key, account, key, value));
34
+ }
35
+
36
+ public struct Dubhe_Store_SetField has copy, drop {
37
+ dapp_key: String,
38
+ account: String,
39
+ key: vector<vector<u8>>,
40
+ field_name: vector<u8>,
41
+ field_value: vector<u8>,
42
+ }
43
+
44
+ public(package) fun emit_store_set_field(
45
+ dapp_key: String,
46
+ account: String,
47
+ key: vector<vector<u8>>,
48
+ field_name: vector<u8>,
49
+ field_value: vector<u8>,
50
+ ) {
51
+ event::emit(Dubhe_Store_SetField { dapp_key, account, key, field_name, field_value });
25
52
  }
26
53
 
27
54
  public struct Dubhe_Store_DeleteRecord has copy, drop {
28
- dapp_key: String,
29
- account: String,
30
- key: vector<vector<u8>>
55
+ dapp_key: String,
56
+ account: String,
57
+ key: vector<vector<u8>>,
58
+ }
59
+
60
+ public(package) fun new_store_delete_record(
61
+ dapp_key: String,
62
+ account: String,
63
+ key: vector<vector<u8>>,
64
+ ): Dubhe_Store_DeleteRecord {
65
+ Dubhe_Store_DeleteRecord { dapp_key, account, key }
66
+ }
67
+
68
+ /// Only dapp_service (same package) may emit storage events.
69
+ public(package) fun emit_store_delete_record(
70
+ dapp_key: String,
71
+ account: String,
72
+ key: vector<vector<u8>>,
73
+ ) {
74
+ event::emit(new_store_delete_record(dapp_key, account, key));
75
+ }
76
+
77
+ public struct Dubhe_Store_DeleteField has copy, drop {
78
+ dapp_key: String,
79
+ account: String,
80
+ key: vector<vector<u8>>,
81
+ field_name: vector<u8>,
82
+ }
83
+
84
+ public(package) fun emit_store_delete_field(
85
+ dapp_key: String,
86
+ account: String,
87
+ key: vector<vector<u8>>,
88
+ field_name: vector<u8>,
89
+ ) {
90
+ event::emit(Dubhe_Store_DeleteField { dapp_key, account, key, field_name });
91
+ }
92
+
93
+ // ─── DApp lifecycle events ────────────────────────────────────────────────────
94
+
95
+ public struct DappCreated has copy, drop {
96
+ dapp_key: String,
97
+ admin: address,
98
+ created_at: u64,
99
+ dapp_storage_id: address,
100
+ }
101
+
102
+ public(package) fun emit_dapp_created(
103
+ dapp_key: String,
104
+ admin: address,
105
+ created_at: u64,
106
+ dapp_storage_id: address,
107
+ ) {
108
+ event::emit(DappCreated { dapp_key, admin, created_at, dapp_storage_id });
109
+ }
110
+
111
+ public struct DappPausedChanged has copy, drop {
112
+ dapp_key: String,
113
+ paused: bool,
114
+ updated_by: address,
115
+ }
116
+
117
+ public(package) fun emit_dapp_paused_changed(
118
+ dapp_key: String,
119
+ paused: bool,
120
+ updated_by: address,
121
+ ) {
122
+ event::emit(DappPausedChanged { dapp_key, paused, updated_by });
123
+ }
124
+
125
+ // ─── Settlement events ────────────────────────────────────────────────────────
126
+
127
+ public struct WritesSettled has copy, drop {
128
+ dapp_key: String,
129
+ account: address,
130
+ writes: u64,
131
+ bytes: u256,
132
+ /// Amount deducted from the DApp's virtual free_credit pool.
133
+ free_cost: u256,
134
+ /// Amount deducted from the DApp's paid credit_pool (real SUI).
135
+ paid_cost: u256,
136
+ }
137
+
138
+ public(package) fun emit_writes_settled(
139
+ dapp_key: String,
140
+ account: address,
141
+ writes: u64,
142
+ bytes: u256,
143
+ free_cost: u256,
144
+ paid_cost: u256,
145
+ ) {
146
+ event::emit(WritesSettled { dapp_key, account, writes, bytes, free_cost, paid_cost });
147
+ }
148
+
149
+ public struct SettlementSkipped has copy, drop {
150
+ dapp_key: String,
151
+ account: address,
152
+ unsettled_writes: u64,
153
+ unsettled_bytes: u256,
154
+ }
155
+
156
+ public(package) fun emit_settlement_skipped(
157
+ dapp_key: String,
158
+ account: address,
159
+ unsettled_writes: u64,
160
+ unsettled_bytes: u256,
161
+ ) {
162
+ event::emit(SettlementSkipped { dapp_key, account, unsettled_writes, unsettled_bytes });
163
+ }
164
+
165
+ public struct SettlementPartial has copy, drop {
166
+ dapp_key: String,
167
+ account: address,
168
+ settled_writes: u64,
169
+ settled_bytes: u256,
170
+ remaining_writes: u64,
171
+ remaining_bytes: u256,
172
+ /// Amount deducted from free_credit for the settled portion.
173
+ free_cost: u256,
174
+ /// Amount deducted from credit_pool for the settled portion.
175
+ paid_cost: u256,
176
+ }
177
+
178
+ public(package) fun emit_settlement_partial(
179
+ dapp_key: String,
180
+ account: address,
181
+ settled_writes: u64,
182
+ settled_bytes: u256,
183
+ remaining_writes: u64,
184
+ remaining_bytes: u256,
185
+ free_cost: u256,
186
+ paid_cost: u256,
187
+ ) {
188
+ event::emit(SettlementPartial {
189
+ dapp_key, account,
190
+ settled_writes, settled_bytes,
191
+ remaining_writes, remaining_bytes,
192
+ free_cost, paid_cost,
193
+ });
194
+ }
195
+
196
+ // ─── Free credit events ───────────────────────────────────────────────────────
197
+
198
+ public struct FreeCreditGranted has copy, drop {
199
+ dapp_key: String,
200
+ amount: u256,
201
+ expires_at: u64,
202
+ granted_by: address,
203
+ }
204
+
205
+ public(package) fun emit_free_credit_granted(
206
+ dapp_key: String,
207
+ amount: u256,
208
+ expires_at: u64,
209
+ granted_by: address,
210
+ ) {
211
+ event::emit(FreeCreditGranted { dapp_key, amount, expires_at, granted_by });
212
+ }
213
+
214
+ public struct FreeCreditRevoked has copy, drop {
215
+ dapp_key: String,
216
+ amount_remaining: u256,
217
+ revoked_by: address,
218
+ }
219
+
220
+ public(package) fun emit_free_credit_revoked(
221
+ dapp_key: String,
222
+ amount_remaining: u256,
223
+ revoked_by: address,
224
+ ) {
225
+ event::emit(FreeCreditRevoked { dapp_key, amount_remaining, revoked_by });
226
+ }
227
+
228
+ public struct FreeCreditExtended has copy, drop {
229
+ dapp_key: String,
230
+ new_expires_at: u64,
231
+ extended_by: address,
232
+ }
233
+
234
+ public(package) fun emit_free_credit_extended(
235
+ dapp_key: String,
236
+ new_expires_at: u64,
237
+ extended_by: address,
238
+ ) {
239
+ event::emit(FreeCreditExtended { dapp_key, new_expires_at, extended_by });
240
+ }
241
+
242
+ // ─── Session key events ───────────────────────────────────────────────────────
243
+
244
+ public struct SessionActivated has copy, drop {
245
+ dapp_key: String,
246
+ canonical: address,
247
+ session_wallet: address,
248
+ expires_at: u64,
249
+ }
250
+
251
+ public(package) fun emit_session_activated(
252
+ dapp_key: String,
253
+ canonical: address,
254
+ session_wallet: address,
255
+ expires_at: u64,
256
+ ) {
257
+ event::emit(SessionActivated { dapp_key, canonical, session_wallet, expires_at });
258
+ }
259
+
260
+ public struct SessionDeactivated has copy, drop {
261
+ dapp_key: String,
262
+ canonical: address,
263
+ session_key: address,
264
+ }
265
+
266
+ public(package) fun emit_session_deactivated(
267
+ dapp_key: String,
268
+ canonical: address,
269
+ session_key: address,
270
+ ) {
271
+ event::emit(SessionDeactivated { dapp_key, canonical, session_key });
272
+ }
273
+
274
+ // ─── Credit events ────────────────────────────────────────────────────────────
275
+
276
+ public struct CreditRecharged has copy, drop {
277
+ dapp_key: String,
278
+ from: address,
279
+ coin_type: String,
280
+ amount: u256,
281
+ }
282
+
283
+ public(package) fun emit_credit_recharged(
284
+ dapp_key: String,
285
+ from: address,
286
+ coin_type: String,
287
+ amount: u256,
288
+ ) {
289
+ event::emit(CreditRecharged { dapp_key, from, coin_type, amount });
290
+ }
291
+
292
+ // ─── Fee events ───────────────────────────────────────────────────────────────
293
+
294
+ public struct FeeUpdated has copy, drop {
295
+ new_base_fee: u256,
296
+ new_bytes_fee: u256,
297
+ at_ms: u64,
298
+ }
299
+
300
+ public(package) fun emit_fee_updated(new_base_fee: u256, new_bytes_fee: u256, at_ms: u64) {
301
+ event::emit(FeeUpdated { new_base_fee, new_bytes_fee, at_ms });
302
+ }
303
+
304
+ public struct FeeUpdateScheduled has copy, drop {
305
+ pending_base_fee: u256,
306
+ pending_bytes_fee: u256,
307
+ effective_at_ms: u64,
308
+ }
309
+
310
+ public(package) fun emit_fee_update_scheduled(
311
+ pending_base_fee: u256,
312
+ pending_bytes_fee: u256,
313
+ effective_at_ms: u64,
314
+ ) {
315
+ event::emit(FeeUpdateScheduled { pending_base_fee, pending_bytes_fee, effective_at_ms });
316
+ }
317
+
318
+ // ─── Coin type events ─────────────────────────────────────────────────────────
319
+
320
+ public struct CoinTypeChangeProposed has copy, drop {
321
+ new_coin_type: String,
322
+ effective_at_ms: u64,
323
+ }
324
+
325
+ public(package) fun emit_coin_type_change_proposed(new_coin_type: String, effective_at_ms: u64) {
326
+ event::emit(CoinTypeChangeProposed { new_coin_type, effective_at_ms });
327
+ }
328
+
329
+ public struct CoinTypeChanged has copy, drop {
330
+ new_coin_type: String,
331
+ }
332
+
333
+ public(package) fun emit_coin_type_changed(new_coin_type: String) {
334
+ event::emit(CoinTypeChanged { new_coin_type });
335
+ }
336
+
337
+ // ─── Settlement mode events ───────────────────────────────────────────────────
338
+
339
+ public struct DappRevenueWithdrawn has copy, drop {
340
+ dapp_key: String,
341
+ admin: address,
342
+ coin_type: String,
343
+ amount: u64,
344
+ }
345
+
346
+ public(package) fun emit_dapp_revenue_withdrawn(
347
+ dapp_key: String,
348
+ admin: address,
349
+ coin_type: String,
350
+ amount: u64,
351
+ ) {
352
+ event::emit(DappRevenueWithdrawn { dapp_key, admin, coin_type, amount });
353
+ }
354
+
355
+ public struct SettlementModeChanged has copy, drop {
356
+ dapp_key: String,
357
+ old_mode: u8,
358
+ new_mode: u8,
359
+ }
360
+
361
+ public(package) fun emit_settlement_mode_changed(dapp_key: String, old_mode: u8, new_mode: u8) {
362
+ event::emit(SettlementModeChanged { dapp_key, old_mode, new_mode });
363
+ }
364
+
365
+ /// Emitted when framework admin sets the revenue share for a specific DApp.
366
+ public struct DappRevenueShareSet has copy, drop {
367
+ dapp_key: String,
368
+ new_bps: u64,
369
+ }
370
+
371
+ public(package) fun emit_dapp_revenue_share_set(dapp_key: String, new_bps: u64) {
372
+ event::emit(DappRevenueShareSet { dapp_key, new_bps });
373
+ }
374
+
375
+ /// Emitted when framework admin updates the global default DApp revenue share.
376
+ public struct DefaultRevenueShareUpdated has copy, drop {
377
+ new_bps: u64,
378
+ }
379
+
380
+ public(package) fun emit_default_revenue_share_updated(new_bps: u64) {
381
+ event::emit(DefaultRevenueShareUpdated { new_bps });
382
+ }
383
+
384
+ /// Emitted when a DApp's package list and version are updated via upgrade_dapp.
385
+ public struct DappUpgraded has copy, drop {
386
+ dapp_key: String,
387
+ new_package_id: address,
388
+ new_version: u32,
389
+ admin: address,
390
+ }
391
+
392
+ public(package) fun emit_dapp_upgraded(
393
+ dapp_key: String,
394
+ new_package_id: address,
395
+ new_version: u32,
396
+ admin: address,
397
+ ) {
398
+ event::emit(DappUpgraded { dapp_key, new_package_id, new_version, admin });
31
399
  }
32
400
 
33
- public fun new_store_delete_record(dapp_key: String, account: String, key: vector<vector<u8>>): Dubhe_Store_DeleteRecord {
34
- Dubhe_Store_DeleteRecord {
35
- dapp_key,
36
- account,
37
- key
38
- }
401
+ /// Emitted when the framework admin changes the global max write limit.
402
+ public struct FrameworkMaxWriteLimitUpdated has copy, drop {
403
+ new_limit: u64,
404
+ admin: address,
39
405
  }
40
406
 
41
- public fun emit_store_delete_record(dapp_key: String, account: String, key: vector<vector<u8>>) {
42
- event::emit(new_store_delete_record(dapp_key, account, key));
43
- }
407
+ public(package) fun emit_framework_max_write_limit_updated(new_limit: u64, admin: address) {
408
+ event::emit(FrameworkMaxWriteLimitUpdated { new_limit, admin });
409
+ }
410
+
411
+ /// Emitted when the framework admin updates the default free credit for future new DApps.
412
+ public struct DefaultFreeCreditUpdated has copy, drop {
413
+ new_amount: u256,
414
+ new_duration_ms: u64,
415
+ updated_by: address,
416
+ }
417
+
418
+ public(package) fun emit_default_free_credit_updated(
419
+ new_amount: u256,
420
+ new_duration_ms: u64,
421
+ updated_by: address,
422
+ ) {
423
+ event::emit(DefaultFreeCreditUpdated { new_amount, new_duration_ms, updated_by });
424
+ }
425
+ public struct UserWriteLimitSynced has copy, drop {
426
+ dapp_key: String,
427
+ owner: address,
428
+ new_limit: u64,
429
+ }
430
+
431
+ public(package) fun emit_user_write_limit_synced(dapp_key: String, owner: address, new_limit: u64) {
432
+ event::emit(UserWriteLimitSynced { dapp_key, owner, new_limit });
433
+ }
434
+
435
+ // ─── Marketplace events ───────────────────────────────────────────────────────
436
+
437
+ /// Emitted when any item is placed into a Listing (unique or fungible).
438
+ public struct ItemListed has copy, drop {
439
+ dapp_key: String,
440
+ listing_id: address,
441
+ seller: address,
442
+ record_type: vector<u8>,
443
+ record_key: vector<vector<u8>>,
444
+ field_names: vector<vector<u8>>,
445
+ /// Field values stored in the listing (one inner vector per field, each BCS-encoded).
446
+ record_data: vector<vector<u8>>,
447
+ price: u64,
448
+ coin_type: String,
449
+ is_fungible: bool,
450
+ listed_until: Option<u64>,
451
+ }
452
+
453
+ public(package) fun emit_item_listed(
454
+ dapp_key: String,
455
+ listing_id: address,
456
+ seller: address,
457
+ record_type: vector<u8>,
458
+ record_key: vector<vector<u8>>,
459
+ field_names: vector<vector<u8>>,
460
+ record_data: vector<vector<u8>>,
461
+ price: u64,
462
+ coin_type: String,
463
+ is_fungible: bool,
464
+ listed_until: Option<u64>,
465
+ ) {
466
+ event::emit(ItemListed {
467
+ dapp_key,
468
+ listing_id,
469
+ seller,
470
+ record_type,
471
+ record_key,
472
+ field_names,
473
+ record_data,
474
+ price,
475
+ coin_type,
476
+ is_fungible,
477
+ listed_until,
478
+ });
479
+ }
480
+
481
+ /// Emitted by settle_marketplace_fee after each successful purchase.
482
+ /// Captures the exact fee split between the framework treasury and the DApp revenue pool,
483
+ /// providing a complete on-chain audit trail for marketplace income.
484
+ public struct MarketplaceFeeSettled has copy, drop {
485
+ dapp_key: String,
486
+ listing_id: address,
487
+ coin_type: String,
488
+ total_fee: u64,
489
+ treasury_amount: u64,
490
+ dapp_amount: u64,
491
+ }
492
+
493
+ public(package) fun emit_marketplace_fee_settled(
494
+ dapp_key: String,
495
+ listing_id: address,
496
+ coin_type: String,
497
+ total_fee: u64,
498
+ treasury_amount: u64,
499
+ dapp_amount: u64,
500
+ ) {
501
+ event::emit(MarketplaceFeeSettled {
502
+ dapp_key, listing_id, coin_type,
503
+ total_fee, treasury_amount, dapp_amount,
504
+ });
505
+ }
506
+
507
+ /// Emitted when a Listing is successfully purchased.
508
+ public struct ItemSold has copy, drop {
509
+ dapp_key: String,
510
+ listing_id: address,
511
+ buyer: address,
512
+ seller: address,
513
+ record_type: vector<u8>,
514
+ price: u64,
515
+ coin_type: String,
516
+ is_fungible: bool,
517
+ }
518
+
519
+ public(package) fun emit_item_sold(
520
+ dapp_key: String,
521
+ listing_id: address,
522
+ buyer: address,
523
+ seller: address,
524
+ record_type: vector<u8>,
525
+ price: u64,
526
+ coin_type: String,
527
+ is_fungible: bool,
528
+ ) {
529
+ event::emit(ItemSold { dapp_key, listing_id, buyer, seller, record_type, price, coin_type, is_fungible });
530
+ }
531
+
532
+ /// Emitted when the seller cancels their own Listing before it expires.
533
+ public struct ListingCancelled has copy, drop {
534
+ dapp_key: String,
535
+ listing_id: address,
536
+ seller: address,
537
+ is_fungible: bool,
538
+ }
539
+
540
+ public(package) fun emit_listing_cancelled(
541
+ dapp_key: String,
542
+ listing_id: address,
543
+ seller: address,
544
+ is_fungible: bool,
545
+ ) {
546
+ event::emit(ListingCancelled { dapp_key, listing_id, seller, is_fungible });
547
+ }
548
+
549
+ /// Emitted when anyone triggers expiry of a past-deadline Listing.
550
+ public struct ListingExpired has copy, drop {
551
+ dapp_key: String,
552
+ listing_id: address,
553
+ seller: address,
554
+ is_fungible: bool,
555
+ }
556
+
557
+ public(package) fun emit_listing_expired(
558
+ dapp_key: String,
559
+ listing_id: address,
560
+ seller: address,
561
+ is_fungible: bool,
562
+ ) {
563
+ event::emit(ListingExpired { dapp_key, listing_id, seller, is_fungible });
564
+ }
565
+
566
+ // ─── ObjectStorage / SceneStorage field events ────────────────────────────────
567
+ //
568
+ // These events are public (not package-internal) because the emit functions must
569
+ // be callable from DApp packages via dapp_system public API. They use distinct
570
+ // event types (not Dubhe_Store_*) so the indexer can route them to separate tables
571
+ // without risk of cross-contamination with UserStorage records.
572
+
573
+ public struct Dubhe_UserStorage_Created has copy, drop {
574
+ dapp_key: String,
575
+ canonical_owner: address,
576
+ user_storage_id: address,
577
+ }
578
+
579
+ public(package) fun emit_user_storage_created(
580
+ dapp_key: String,
581
+ canonical_owner: address,
582
+ user_storage_id: address,
583
+ ) {
584
+ event::emit(Dubhe_UserStorage_Created { dapp_key, canonical_owner, user_storage_id });
585
+ }
586
+
587
+ public struct Dubhe_Object_Created has copy, drop {
588
+ dapp_key: String,
589
+ object_type: vector<u8>,
590
+ object_id: address,
591
+ entity_id: vector<u8>,
592
+ }
593
+
594
+ public(package) fun emit_object_created(
595
+ dapp_key: String,
596
+ object_type: vector<u8>,
597
+ object_id: address,
598
+ entity_id: vector<u8>,
599
+ ) {
600
+ event::emit(Dubhe_Object_Created { dapp_key, object_type, object_id, entity_id });
601
+ }
602
+
603
+ public struct Dubhe_Object_Destroyed has copy, drop {
604
+ dapp_key: String,
605
+ object_type: vector<u8>,
606
+ object_id: address,
607
+ entity_id: vector<u8>,
608
+ }
609
+
610
+ public(package) fun emit_object_destroyed(
611
+ dapp_key: String,
612
+ object_type: vector<u8>,
613
+ object_id: address,
614
+ entity_id: vector<u8>,
615
+ ) {
616
+ event::emit(Dubhe_Object_Destroyed { dapp_key, object_type, object_id, entity_id });
617
+ }
618
+
619
+ /// Emitted whenever a field is set (inserted or updated) in an ObjectStorage Bag.
620
+ public struct Dubhe_Object_SetField has copy, drop {
621
+ dapp_key: String,
622
+ object_type: vector<u8>,
623
+ object_id: address,
624
+ field_name: vector<u8>,
625
+ field_value: vector<u8>,
626
+ }
627
+
628
+ public(package) fun emit_object_set_field(
629
+ dapp_key: String,
630
+ object_type: vector<u8>,
631
+ object_id: address,
632
+ field_name: vector<u8>,
633
+ field_value: vector<u8>,
634
+ ) {
635
+ event::emit(Dubhe_Object_SetField { dapp_key, object_type, object_id, field_name, field_value });
636
+ }
637
+
638
+ /// Emitted whenever a field is removed from an ObjectStorage Bag.
639
+ public struct Dubhe_Object_DeleteField has copy, drop {
640
+ dapp_key: String,
641
+ object_type: vector<u8>,
642
+ object_id: address,
643
+ field_name: vector<u8>,
644
+ }
645
+
646
+ public(package) fun emit_object_delete_field(
647
+ dapp_key: String,
648
+ object_type: vector<u8>,
649
+ object_id: address,
650
+ field_name: vector<u8>,
651
+ ) {
652
+ event::emit(Dubhe_Object_DeleteField { dapp_key, object_type, object_id, field_name });
653
+ }
654
+
655
+ public struct Dubhe_Scene_Created has copy, drop {
656
+ dapp_key: String,
657
+ scene_type: vector<u8>,
658
+ scene_id: address,
659
+ authorization_kind: vector<u8>,
660
+ authorized_permit_id: Option<address>,
661
+ }
662
+
663
+ public(package) fun emit_scene_created(
664
+ dapp_key: String,
665
+ scene_type: vector<u8>,
666
+ scene_id: address,
667
+ authorization_kind: vector<u8>,
668
+ authorized_permit_id: Option<address>,
669
+ ) {
670
+ event::emit(Dubhe_Scene_Created {
671
+ dapp_key,
672
+ scene_type,
673
+ scene_id,
674
+ authorization_kind,
675
+ authorized_permit_id,
676
+ });
677
+ }
678
+
679
+ public struct Dubhe_Scene_Destroyed has copy, drop {
680
+ dapp_key: String,
681
+ scene_type: vector<u8>,
682
+ scene_id: address,
683
+ authorized_permit_id: Option<address>,
684
+ }
685
+
686
+ public(package) fun emit_scene_destroyed(
687
+ dapp_key: String,
688
+ scene_type: vector<u8>,
689
+ scene_id: address,
690
+ authorized_permit_id: Option<address>,
691
+ ) {
692
+ event::emit(Dubhe_Scene_Destroyed { dapp_key, scene_type, scene_id, authorized_permit_id });
693
+ }
694
+
695
+ /// Emitted whenever a field is set (inserted or updated) in a SceneStorage Bag.
696
+ public struct Dubhe_Scene_SetField has copy, drop {
697
+ dapp_key: String,
698
+ scene_type: vector<u8>,
699
+ scene_id: address,
700
+ field_name: vector<u8>,
701
+ field_value: vector<u8>,
702
+ }
703
+
704
+ public(package) fun emit_scene_set_field(
705
+ dapp_key: String,
706
+ scene_type: vector<u8>,
707
+ scene_id: address,
708
+ field_name: vector<u8>,
709
+ field_value: vector<u8>,
710
+ ) {
711
+ event::emit(Dubhe_Scene_SetField { dapp_key, scene_type, scene_id, field_name, field_value });
712
+ }
713
+
714
+ /// Emitted whenever a field is removed from a SceneStorage Bag.
715
+ public struct Dubhe_Scene_DeleteField has copy, drop {
716
+ dapp_key: String,
717
+ scene_type: vector<u8>,
718
+ scene_id: address,
719
+ field_name: vector<u8>,
720
+ }
721
+
722
+ public(package) fun emit_scene_delete_field(
723
+ dapp_key: String,
724
+ scene_type: vector<u8>,
725
+ scene_id: address,
726
+ field_name: vector<u8>,
727
+ ) {
728
+ event::emit(Dubhe_Scene_DeleteField { dapp_key, scene_type, scene_id, field_name });
729
+ }
730
+
731
+ // ─── ScenePermit lifecycle / participant events ───────────────────────────────
732
+
733
+ public struct Dubhe_ScenePermit_Created has copy, drop {
734
+ dapp_key: String,
735
+ permit_type: vector<u8>,
736
+ permit_id: address,
737
+ expires_at: Option<u64>,
738
+ invites_expire_at: Option<u64>,
739
+ max_participants: Option<u64>,
740
+ participant_count: u64,
741
+ }
742
+
743
+ public(package) fun emit_scene_permit_created(
744
+ dapp_key: String,
745
+ permit_type: vector<u8>,
746
+ permit_id: address,
747
+ expires_at: Option<u64>,
748
+ invites_expire_at: Option<u64>,
749
+ max_participants: Option<u64>,
750
+ participant_count: u64,
751
+ ) {
752
+ event::emit(Dubhe_ScenePermit_Created {
753
+ dapp_key,
754
+ permit_type,
755
+ permit_id,
756
+ expires_at,
757
+ invites_expire_at,
758
+ max_participants,
759
+ participant_count,
760
+ });
761
+ }
762
+
763
+ public struct Dubhe_ScenePermit_Accept has copy, drop {
764
+ dapp_key: String,
765
+ permit_type: vector<u8>,
766
+ permit_id: address,
767
+ participant: address,
768
+ }
769
+
770
+ public(package) fun emit_scene_permit_accept(
771
+ dapp_key: String,
772
+ permit_type: vector<u8>,
773
+ permit_id: address,
774
+ participant: address,
775
+ ) {
776
+ event::emit(Dubhe_ScenePermit_Accept { dapp_key, permit_type, permit_id, participant });
777
+ }
778
+
779
+ public struct Dubhe_ScenePermit_Join has copy, drop {
780
+ dapp_key: String,
781
+ permit_type: vector<u8>,
782
+ permit_id: address,
783
+ participant: address,
784
+ }
785
+
786
+ public(package) fun emit_scene_permit_join(
787
+ dapp_key: String,
788
+ permit_type: vector<u8>,
789
+ permit_id: address,
790
+ participant: address,
791
+ ) {
792
+ event::emit(Dubhe_ScenePermit_Join { dapp_key, permit_type, permit_id, participant });
793
+ }
794
+
795
+ public struct Dubhe_ScenePermit_Leave has copy, drop {
796
+ dapp_key: String,
797
+ permit_type: vector<u8>,
798
+ permit_id: address,
799
+ participant: address,
800
+ }
801
+
802
+ public(package) fun emit_scene_permit_leave(
803
+ dapp_key: String,
804
+ permit_type: vector<u8>,
805
+ permit_id: address,
806
+ participant: address,
807
+ ) {
808
+ event::emit(Dubhe_ScenePermit_Leave { dapp_key, permit_type, permit_id, participant });
809
+ }
810
+
811
+ public struct Dubhe_ScenePermit_Expire has copy, drop {
812
+ dapp_key: String,
813
+ permit_type: vector<u8>,
814
+ permit_id: address,
815
+ }
816
+
817
+ public(package) fun emit_scene_permit_expire(
818
+ dapp_key: String,
819
+ permit_type: vector<u8>,
820
+ permit_id: address,
821
+ ) {
822
+ event::emit(Dubhe_ScenePermit_Expire { dapp_key, permit_type, permit_id });
823
+ }
824
+
825
+ /// Emitted when the framework admin calls update_marketplace_fee.
826
+ public struct Dubhe_Marketplace_FeeUpdated has copy, drop {
827
+ fee_bps: u64,
828
+ }
829
+
830
+ public(package) fun emit_marketplace_fee_updated(fee_bps: u64) {
831
+ event::emit(Dubhe_Marketplace_FeeUpdated { fee_bps });
832
+ }
833
+
834
+ // ─── Framework fee/revenue state snapshots ────────────────────────────────────
835
+ // These are dedicated (non-Store-backed) events so the indexer can handle them
836
+ // with hardcoded Rust logic — identical to the marketplace / session event path.
837
+
838
+ /// Emitted after every operation that mutates the credit pool or fee rates of a DApp.
839
+ /// Snapshots the full fee-state so the indexer can maintain store_dapp_fee_state.
840
+ public struct DappFeeStateUpdated has copy, drop {
841
+ dapp_key: String,
842
+ base_fee_per_write: u256,
843
+ bytes_fee_per_byte: u256,
844
+ free_credit: u256,
845
+ credit_pool: u256,
846
+ total_settled: u256,
847
+ }
848
+
849
+ public(package) fun emit_dapp_fee_state_updated(
850
+ dapp_key: String,
851
+ base_fee_per_write: u256,
852
+ bytes_fee_per_byte: u256,
853
+ free_credit: u256,
854
+ credit_pool: u256,
855
+ total_settled: u256,
856
+ ) {
857
+ event::emit(DappFeeStateUpdated {
858
+ dapp_key,
859
+ base_fee_per_write,
860
+ bytes_fee_per_byte,
861
+ free_credit,
862
+ credit_pool,
863
+ total_settled,
864
+ });
865
+ }
866
+
867
+ /// Emitted after every operation that changes the pending DApp revenue balance
868
+ /// (settle_writes_user_pays, settle_marketplace_fee).
869
+ /// Snapshots dapp_revenue so the indexer can maintain store_dapp_revenue_state.
870
+ public struct DappRevenueStateUpdated has copy, drop {
871
+ dapp_key: String,
872
+ dapp_revenue: u64,
873
+ coin_type: String,
874
+ }
875
+
876
+ public(package) fun emit_dapp_revenue_state_updated(
877
+ dapp_key: String,
878
+ dapp_revenue: u64,
879
+ coin_type: String,
880
+ ) {
881
+ event::emit(DappRevenueStateUpdated { dapp_key, dapp_revenue, coin_type });
882
+ }