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.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +16 -16
- package/templates/101/sui-template/docker-compose.testnet.yml +73 -0
- package/templates/101/sui-template/packages/client/src/app/page.tsx +545 -41
- package/templates/101/sui-template/packages/client/src/app/providers.tsx +12 -4
- package/templates/101/sui-template/packages/contracts/Pub.localnet.toml +4 -4
- package/templates/101/sui-template/packages/contracts/counter.lock.json +20 -0
- package/templates/101/sui-template/packages/contracts/deployment.ts +8 -3
- package/templates/101/sui-template/packages/contracts/dubhe.config.json +59 -13
- package/templates/101/sui-template/packages/contracts/dubhe.config.ts +1 -4
- package/templates/101/sui-template/packages/contracts/metadata.json +1015 -68
- package/templates/101/sui-template/packages/contracts/package.json +7 -4
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/dapp_key.move +45 -31
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/error.move +8 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/genesis.move +30 -13
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/init_test.move +19 -14
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2.move +198 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2withkey.move +90 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/value.move +30 -20
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/scripts/deploy_hook.move +6 -11
- package/templates/101/sui-template/packages/contracts/src/counter/sources/systems/counter.move +23 -11
- package/templates/101/sui-template/packages/contracts/src/counter/sources/tests/counter.move +15 -14
- package/templates/101/sui-template/packages/contracts/src/dubhe/Move.lock +33 -30
- package/templates/101/sui-template/packages/contracts/src/dubhe/Move.toml +8 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/dapp_key.move +45 -31
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/error.move +170 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/genesis.move +16 -13
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/init_test.move +8 -14
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/account_key.move +1 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/dapp_service.move +1776 -137
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/data_key.move +1 -20
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/events.move +864 -25
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/scripts/deploy_hook.move +15 -16
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/scripts/migrate.move +0 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/address_system.move +25 -17
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/dapp_system.move +2802 -343
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/utils.move +1 -1
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/address.move +173 -55
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/dapp_test.move +769 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/fee_test.move +2965 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/integration_test.move +303 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/listing_test.move +1422 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/scene_session_test.move +269 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/session_test.move +624 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/storage_test.move +700 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/typed_object_test.move +177 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/typed_scene_test.move +452 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/user_storage_test.move +160 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/utils/math.move +4 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/utils/type_info.move +2 -2
- package/templates/contract/sui-template/dubhe.config.ts +0 -1
- package/templates/contract/sui-template/package.json +3 -3
- package/templates/contract/sui-template/src/dubhe/Move.lock +33 -30
- package/templates/contract/sui-template/src/dubhe/Move.toml +8 -3
- package/templates/contract/sui-template/src/dubhe/sources/codegen/dapp_key.move +45 -31
- package/templates/contract/sui-template/src/dubhe/sources/codegen/error.move +170 -0
- package/templates/contract/sui-template/src/dubhe/sources/codegen/genesis.move +16 -13
- package/templates/contract/sui-template/src/dubhe/sources/codegen/init_test.move +8 -14
- package/templates/contract/sui-template/src/dubhe/sources/core/account_key.move +1 -3
- package/templates/contract/sui-template/src/dubhe/sources/core/dapp_service.move +1776 -137
- package/templates/contract/sui-template/src/dubhe/sources/core/data_key.move +1 -20
- package/templates/contract/sui-template/src/dubhe/sources/core/events.move +864 -25
- package/templates/contract/sui-template/src/dubhe/sources/scripts/deploy_hook.move +15 -16
- package/templates/contract/sui-template/src/dubhe/sources/scripts/migrate.move +0 -3
- package/templates/contract/sui-template/src/dubhe/sources/systems/address_system.move +25 -17
- package/templates/contract/sui-template/src/dubhe/sources/systems/dapp_system.move +2802 -343
- package/templates/contract/sui-template/src/dubhe/sources/systems/utils.move +1 -1
- package/templates/contract/sui-template/src/dubhe/sources/tests/address.move +173 -55
- package/templates/contract/sui-template/src/dubhe/sources/tests/dapp_test.move +769 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/fee_test.move +2965 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/integration_test.move +303 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/listing_test.move +1422 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/scene_session_test.move +269 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/session_test.move +624 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/storage_test.move +700 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/typed_object_test.move +177 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/typed_scene_test.move +452 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/user_storage_test.move +160 -0
- package/templates/contract/sui-template/src/dubhe/sources/utils/math.move +4 -3
- package/templates/contract/sui-template/src/dubhe/sources/utils/type_info.move +2 -2
- package/templates/contract/sui-template/src/template/Move.toml +12 -0
- package/templates/contract/sui-template/src/template/sources/codegen/dapp_key.move +47 -0
- package/templates/contract/sui-template/src/template/sources/codegen/genesis.move +34 -0
- package/templates/contract/sui-template/src/template/sources/codegen/init_test.move +23 -0
- package/templates/contract/sui-template/src/template/sources/codegen/user_storage_init.move +27 -0
- package/templates/contract/sui-template/src/template/sources/scripts/deploy_hook.move +13 -0
- package/templates/contract/sui-template/src/template/sources/scripts/migrate.move +7 -0
- package/templates/nextjs/sui-card-duel/.gitignore_ +51 -0
- package/templates/nextjs/sui-card-duel/README.md +213 -0
- package/templates/nextjs/sui-card-duel/docker-compose.yml +34 -0
- package/templates/nextjs/sui-card-duel/mprocs.yaml +17 -0
- package/templates/nextjs/sui-card-duel/package.json +43 -0
- package/templates/nextjs/sui-card-duel/packages/client/.gitignore_ +48 -0
- package/templates/nextjs/sui-card-duel/packages/client/.prettierignore +1 -0
- package/templates/nextjs/sui-card-duel/packages/client/.prettierrc.json +8 -0
- package/templates/nextjs/sui-card-duel/packages/client/eslint.config.mjs +22 -0
- package/templates/nextjs/sui-card-duel/packages/client/next.config.mjs +8 -0
- package/templates/nextjs/sui-card-duel/packages/client/package.json +47 -0
- package/templates/nextjs/sui-card-duel/packages/client/postcss.config.mjs +8 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/admin/ArenaPanel.tsx +307 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/admin/page.tsx +622 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/brawl/[id]/page.tsx +559 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/collection/page.tsx +202 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/components/CardView.tsx +66 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/components/GameShell.tsx +294 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/components/icons.tsx +101 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/duel/[id]/page.tsx +477 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/favicon.ico +0 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/globals.css +85 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/hooks/useGame.ts +313 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/layout.tsx +24 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/leaderboard/page.tsx +123 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/lib/game.ts +77 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/lib/scenes.ts +226 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/market/page.tsx +418 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/page.tsx +427 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/providers.tsx +69 -0
- package/templates/nextjs/sui-card-duel/packages/client/tailwind.config.ts +21 -0
- package/templates/nextjs/sui-card-duel/packages/client/tsconfig.json +30 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/.gitignore_ +51 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/.prettierignore +1 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/.prettierrc.json +8 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/Dockerfile +5 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/Pub.localnet.toml +13 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/card_duel.lock.json +66 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/docker-compose.yml +34 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/dubhe.config.ts +150 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/logs/combined.log +31383 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/package.json +49 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/config.ts +17 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-brawl.ts +270 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-duel.ts +272 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-lobby.ts +177 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-market.ts +219 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-session.ts +342 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/query-dapp-revenue.ts +95 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/seed.ts +92 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/withdraw-dapp-revenue.ts +56 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/Move.toml +15 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/dapp_key.move +46 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/card_kind.move +47 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/match_state.move +37 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/rarity.move +37 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/error.move +126 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/genesis.move +33 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/init_test.move +23 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/objects/arena.move +137 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/permits/brawl_permit.move +125 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/permits/duel_permit.move +125 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/battle_state.move +255 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/card.move +282 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/deck.move +64 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/game_config.move +267 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/gold.move +205 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/profile.move +255 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/scenes/brawl.move +313 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/scenes/duel.move +313 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/scripts/deploy_hook.move +32 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/scripts/migrate.move +7 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/arena_system.move +57 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/brawl_system.move +559 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/card_system.move +146 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/duel_system.move +515 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/market_system.move +115 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/player_system.move +37 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/brawl_tests.move +385 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/duel_tests.move +656 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/test_helpers.move +31 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/sui-indexer-schema.graphql +5973 -0
- package/templates/nextjs/sui-card-duel/pnpm-workspace.yaml +2 -0
- package/templates/nextjs/sui-farm/.gitignore_ +51 -0
- package/templates/nextjs/sui-farm/README.md +15 -0
- package/templates/nextjs/sui-farm/UPGRADE_NOTES.md +97 -0
- package/templates/nextjs/sui-farm/docker-compose.yml +34 -0
- package/templates/nextjs/sui-farm/mprocs.yaml +17 -0
- package/templates/nextjs/sui-farm/package.json +43 -0
- package/templates/nextjs/sui-farm/packages/client/.gitignore_ +48 -0
- package/templates/nextjs/sui-farm/packages/client/.prettierignore +1 -0
- package/templates/nextjs/sui-farm/packages/client/.prettierrc.json +8 -0
- package/templates/nextjs/sui-farm/packages/client/eslint.config.mjs +22 -0
- package/templates/nextjs/sui-farm/packages/client/next.config.mjs +8 -0
- package/templates/nextjs/sui-farm/packages/client/package.json +47 -0
- package/templates/nextjs/sui-farm/packages/client/postcss.config.mjs +8 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/admin/page.tsx +618 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/FarmLand.tsx +526 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/FarmPlotCard.tsx +215 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/PetAvatar.tsx +868 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/PetPanel.tsx +1360 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/PlantModal.tsx +147 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/ProxyCard.tsx +684 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/RanchLand.tsx +822 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/ResourceHUD.tsx +125 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/ShopPanel.tsx +232 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/icons/GameIcons.tsx +574 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/favicon.ico +0 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/globals.css +423 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/hooks/useWorldPermitId.ts +66 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/layout.tsx +23 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/leaderboard/page.tsx +185 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/lib/crops.ts +97 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/market/page.tsx +763 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/page.tsx +1173 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/providers.tsx +69 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/state/index.tsx +5 -0
- package/templates/nextjs/sui-farm/packages/client/tailwind.config.ts +25 -0
- package/templates/nextjs/sui-farm/packages/client/tsconfig.json +30 -0
- package/templates/nextjs/sui-farm/packages/contracts/.gitignore_ +51 -0
- package/templates/nextjs/sui-farm/packages/contracts/.prettierignore +1 -0
- package/templates/nextjs/sui-farm/packages/contracts/.prettierrc.json +8 -0
- package/templates/nextjs/sui-farm/packages/contracts/Dockerfile +5 -0
- package/templates/nextjs/sui-farm/packages/contracts/Pub.localnet.toml +13 -0
- package/templates/nextjs/sui-farm/packages/contracts/counter.lock.json +14 -0
- package/templates/nextjs/sui-farm/packages/contracts/docker-compose.yml +34 -0
- package/templates/nextjs/sui-farm/packages/contracts/dubhe.config.ts +178 -0
- package/templates/nextjs/sui-farm/packages/contracts/harvest.lock.json +120 -0
- package/templates/nextjs/sui-farm/packages/contracts/package.json +48 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/config.ts +17 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/query-dapp-revenue.ts +95 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/read-permit.ts +72 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/seed.ts +85 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/withdraw-dapp-revenue.ts +56 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/Move.toml +14 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/dapp_key.move +31 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/error.move +10 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/genesis.move +33 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/init_test.move +23 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/resources/counter1.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/resources/counter2.move +70 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/scripts/deploy_hook.move +8 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/scripts/migrate.move +8 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/systems/counter.move +13 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/tests/counter.move +28 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/Move.toml +14 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/dapp_key.move +46 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/crop_type.move +47 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/egg_type.move +42 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/pet_rarity.move +37 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/pet_species.move +52 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/error.move +110 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/genesis.move +33 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/init_test.move +23 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/permits/world.move +125 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/carrot.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/carrot_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/common_egg.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/corn.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/corn_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/crow_charges.move +162 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/crow_damage.move +207 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/farm_plot.move +261 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/gold.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet.move +467 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_config.move +372 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_hatch.move +162 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_slot_index.move +83 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_slots.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/profile.move +162 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pumpkin.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pumpkin_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/rare_egg.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/scarecrow.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/season_config.move +197 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/season_stats.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/seasonal_egg.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/shop_config.move +267 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/trophy.move +245 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/wheat.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/wheat_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/world_permit_id.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/scripts/deploy_hook.move +45 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/scripts/migrate.move +7 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/crow_system.move +96 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/farm_system.move +182 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/market_system.move +172 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/pet_system.move +495 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/season_system.move +70 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/shop_system.move +112 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/world_system.move +34 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/tests/farm_tests.move +1192 -0
- package/templates/nextjs/sui-farm/pnpm-workspace.yaml +2 -0
- package/templates/nextjs/sui-template/packages/client/src/app/components/ProxyCard.tsx +683 -0
- package/templates/nextjs/sui-template/packages/client/src/app/page.tsx +510 -5
- package/templates/nextjs/sui-template/packages/client/src/app/providers.tsx +13 -5
- package/templates/nextjs/sui-template/packages/contracts/Pub.localnet.toml +4 -4
- package/templates/nextjs/sui-template/packages/contracts/counter.lock.json +14 -0
- package/templates/nextjs/sui-template/packages/contracts/deployment.ts +8 -3
- package/templates/nextjs/sui-template/packages/contracts/dubhe.config.json +9 -9
- package/templates/nextjs/sui-template/packages/contracts/dubhe.config.ts +0 -4
- package/templates/nextjs/sui-template/packages/contracts/metadata.json +180 -124
- package/templates/nextjs/sui-template/packages/contracts/package.json +8 -4
- package/templates/nextjs/sui-template/packages/contracts/src/counter/Move.toml +4 -0
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/dapp_key.move +45 -31
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/error.move +10 -0
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/genesis.move +30 -13
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/init_test.move +19 -14
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter1.move +30 -20
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2.move +35 -24
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/scripts/deploy_hook.move +6 -10
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/systems/counter.move +7 -20
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/tests/counter.move +14 -27
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/Move.lock +33 -30
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/Move.toml +8 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/dapp_key.move +45 -31
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/error.move +170 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/genesis.move +16 -13
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/init_test.move +8 -14
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/account_key.move +1 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/dapp_service.move +1776 -137
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/data_key.move +1 -20
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/events.move +864 -25
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/scripts/deploy_hook.move +15 -16
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/scripts/migrate.move +0 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/address_system.move +25 -17
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/dapp_system.move +2802 -343
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/utils.move +1 -1
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/address.move +173 -55
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/dapp_test.move +769 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/fee_test.move +2965 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/integration_test.move +303 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/listing_test.move +1422 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/scene_session_test.move +269 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/session_test.move +624 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/storage_test.move +700 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/typed_object_test.move +177 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/typed_scene_test.move +452 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/user_storage_test.move +160 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/utils/math.move +4 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/utils/type_info.move +2 -2
- package/templates/101/sui-template/packages/contracts/src/counter/Move.lock +0 -41
- package/templates/101/sui-template/packages/contracts/src/counter/Published.toml +0 -9
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/errors.move +0 -12
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/errors.move +0 -140
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/dapp_store.move +0 -29
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/session_system.move +0 -44
- package/templates/contract/sui-template/src/dubhe/sources/codegen/errors.move +0 -140
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
- package/templates/contract/sui-template/src/dubhe/sources/core/dapp_store.move +0 -29
- package/templates/contract/sui-template/src/dubhe/sources/systems/session_system.move +0 -44
- package/templates/nextjs/sui-template/packages/contracts/src/counter/Move.lock +0 -47
- package/templates/nextjs/sui-template/packages/contracts/src/counter/Published.toml +0 -9
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/errors.move +0 -12
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/errors.move +0 -140
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/dapp_store.move +0 -29
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/session_system.move +0 -44
package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/crow_system.move
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module harvest::crow_system {
|
|
2
|
+
use sui::clock::Clock;
|
|
3
|
+
use dubhe::dapp_service::{DappStorage, UserStorage, ScenePermit};
|
|
4
|
+
use dubhe::dapp_service;
|
|
5
|
+
use dubhe::dapp_system;
|
|
6
|
+
use harvest::dapp_key::DappKey;
|
|
7
|
+
use harvest::migrate;
|
|
8
|
+
use harvest::error;
|
|
9
|
+
use harvest::gold;
|
|
10
|
+
use harvest::crow_charges;
|
|
11
|
+
use harvest::crow_damage;
|
|
12
|
+
use harvest::scarecrow;
|
|
13
|
+
use harvest::profile;
|
|
14
|
+
use harvest::world::World;
|
|
15
|
+
|
|
16
|
+
const CROW_CHARGE_REFILL_MS: u64 = 60 * 60 * 1000;
|
|
17
|
+
const MAX_CROW_CHARGES: u8 = 3;
|
|
18
|
+
const CROW_DAMAGE_PCT: u8 = 30;
|
|
19
|
+
const CROW_DEBUFF_DURATION: u64 = 4 * 60 * 60 * 1000;
|
|
20
|
+
const SCARECROW_DURATION: u64 = 4 * 60 * 60 * 1000;
|
|
21
|
+
const SCARECROW_COST: u64 = 10;
|
|
22
|
+
|
|
23
|
+
#[error]
|
|
24
|
+
const ESelfAttack: vector<u8> = b"Cannot attack yourself";
|
|
25
|
+
|
|
26
|
+
/// Attack a target player with crows. Consumes 1 crow charge and sets a
|
|
27
|
+
/// 30% harvest-debuff on the target for 4 hours via reactive write.
|
|
28
|
+
public entry fun attack(
|
|
29
|
+
dapp_storage: &DappStorage,
|
|
30
|
+
attacker_storage: &mut UserStorage,
|
|
31
|
+
target_storage: &mut UserStorage,
|
|
32
|
+
world_permit: &mut ScenePermit<World>,
|
|
33
|
+
clock: &Clock,
|
|
34
|
+
ctx: &mut TxContext,
|
|
35
|
+
) {
|
|
36
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
37
|
+
error::not_registered(profile::has(attacker_storage));
|
|
38
|
+
error::not_registered(profile::has(target_storage));
|
|
39
|
+
|
|
40
|
+
let now = sui::clock::timestamp_ms(clock);
|
|
41
|
+
let attacker = ctx.sender();
|
|
42
|
+
let target_addr = dapp_service::canonical_owner(target_storage);
|
|
43
|
+
assert!(attacker != target_addr, ESelfAttack);
|
|
44
|
+
|
|
45
|
+
maybe_refill_charges(attacker_storage, now, ctx);
|
|
46
|
+
|
|
47
|
+
let charges = crow_charges::get_count(attacker_storage);
|
|
48
|
+
error::crow_no_charges(charges > 0);
|
|
49
|
+
|
|
50
|
+
let target_protected = scarecrow::has(target_storage) &&
|
|
51
|
+
now < scarecrow::get(target_storage);
|
|
52
|
+
error::crow_target_protected(!target_protected);
|
|
53
|
+
|
|
54
|
+
crow_charges::set_count(attacker_storage, charges - 1, ctx);
|
|
55
|
+
|
|
56
|
+
crow_damage::set_reactive(
|
|
57
|
+
world_permit,
|
|
58
|
+
attacker_storage,
|
|
59
|
+
target_storage,
|
|
60
|
+
now + CROW_DEBUFF_DURATION,
|
|
61
|
+
CROW_DAMAGE_PCT,
|
|
62
|
+
ctx,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// Place a scarecrow to protect your farm for 4 hours.
|
|
67
|
+
public entry fun place_scarecrow(
|
|
68
|
+
dapp_storage: &DappStorage,
|
|
69
|
+
user_storage: &mut UserStorage,
|
|
70
|
+
clock: &Clock,
|
|
71
|
+
ctx: &mut TxContext,
|
|
72
|
+
) {
|
|
73
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
74
|
+
error::not_registered(profile::has(user_storage));
|
|
75
|
+
error::insufficient_gold(gold::get(user_storage) >= SCARECROW_COST);
|
|
76
|
+
|
|
77
|
+
let now = sui::clock::timestamp_ms(clock);
|
|
78
|
+
gold::sub(user_storage, SCARECROW_COST, ctx);
|
|
79
|
+
scarecrow::set(user_storage, now + SCARECROW_DURATION, ctx);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
83
|
+
|
|
84
|
+
fun maybe_refill_charges(user_storage: &mut UserStorage, now: u64, ctx: &mut TxContext) {
|
|
85
|
+
if (!crow_charges::has(user_storage)) { return };
|
|
86
|
+
let last_refill = crow_charges::get_last_refill_at(user_storage);
|
|
87
|
+
let current = crow_charges::get_count(user_storage);
|
|
88
|
+
if (current >= MAX_CROW_CHARGES || last_refill == 0) { return };
|
|
89
|
+
let elapsed = now - last_refill;
|
|
90
|
+
let earned = ((elapsed / CROW_CHARGE_REFILL_MS) as u8);
|
|
91
|
+
if (earned == 0) { return };
|
|
92
|
+
let new_count = current + earned;
|
|
93
|
+
let clamped = if (new_count > MAX_CROW_CHARGES) { MAX_CROW_CHARGES } else { new_count };
|
|
94
|
+
crow_charges::set(user_storage, clamped, now, ctx);
|
|
95
|
+
}
|
|
96
|
+
}
|
package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/farm_system.move
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
module harvest::farm_system {
|
|
2
|
+
use sui::clock::Clock;
|
|
3
|
+
use dubhe::dapp_service::{DappStorage, UserStorage};
|
|
4
|
+
use dubhe::dapp_system;
|
|
5
|
+
use harvest::dapp_key::DappKey;
|
|
6
|
+
use harvest::migrate;
|
|
7
|
+
use harvest::error;
|
|
8
|
+
use harvest::wheat_seed;
|
|
9
|
+
use harvest::corn_seed;
|
|
10
|
+
use harvest::carrot_seed;
|
|
11
|
+
use harvest::pumpkin_seed;
|
|
12
|
+
use harvest::wheat;
|
|
13
|
+
use harvest::corn;
|
|
14
|
+
use harvest::carrot;
|
|
15
|
+
use harvest::pumpkin;
|
|
16
|
+
use harvest::farm_plot;
|
|
17
|
+
use harvest::profile;
|
|
18
|
+
use harvest::season_config;
|
|
19
|
+
use harvest::season_stats;
|
|
20
|
+
use harvest::crow_damage;
|
|
21
|
+
|
|
22
|
+
const CROP_NONE: u8 = 0;
|
|
23
|
+
const CROP_WHEAT: u8 = 1;
|
|
24
|
+
const CROP_CORN: u8 = 2;
|
|
25
|
+
const CROP_CARROT: u8 = 3;
|
|
26
|
+
const CROP_PUMPKIN: u8 = 4;
|
|
27
|
+
|
|
28
|
+
// Growth durations
|
|
29
|
+
const WHEAT_MS: u64 = 1 * 60 * 1000;
|
|
30
|
+
const CORN_MS: u64 = 2 * 60 * 1000;
|
|
31
|
+
const CARROT_MS: u64 = 4 * 60 * 1000;
|
|
32
|
+
const PUMPKIN_MS: u64 = 5 * 60 * 1000;
|
|
33
|
+
|
|
34
|
+
// Harvest yield per seed planted (cheap crops = more yield, expensive = less)
|
|
35
|
+
const WHEAT_YIELD: u64 = 6; // cheap & fast → 6x
|
|
36
|
+
const CORN_YIELD: u64 = 4; // medium → 4x
|
|
37
|
+
const CARROT_YIELD: u64 = 3; // expensive → 3x
|
|
38
|
+
const PUMPKIN_YIELD: u64 = 3; // medium-exp → 3x
|
|
39
|
+
|
|
40
|
+
const SEASON_BONUS_PCT: u64 = 200;
|
|
41
|
+
|
|
42
|
+
/// Plant seeds on farm plot `plot_id`.
|
|
43
|
+
/// Consumes exactly 1 seed from the dedicated seed inventory.
|
|
44
|
+
/// The stored count equals the crop's yield multiplier,
|
|
45
|
+
/// so harvesting returns yield_per_seed crops.
|
|
46
|
+
public entry fun plant(
|
|
47
|
+
dapp_storage: &DappStorage,
|
|
48
|
+
user_storage: &mut UserStorage,
|
|
49
|
+
plot_id: u8,
|
|
50
|
+
crop_type: u8,
|
|
51
|
+
clock: &Clock,
|
|
52
|
+
ctx: &mut TxContext,
|
|
53
|
+
) {
|
|
54
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
55
|
+
error::not_registered(profile::has(user_storage));
|
|
56
|
+
error::invalid_crop_type(crop_type >= CROP_WHEAT && crop_type <= CROP_PUMPKIN);
|
|
57
|
+
|
|
58
|
+
let plots_owned = profile::get_plots_owned(user_storage);
|
|
59
|
+
error::plot_not_found(plot_id < plots_owned);
|
|
60
|
+
|
|
61
|
+
if (farm_plot::has(user_storage, plot_id)) {
|
|
62
|
+
let existing_crop = farm_plot::get_crop_type(user_storage, plot_id);
|
|
63
|
+
error::plot_already_planted(existing_crop == CROP_NONE);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Check seed balance before deducting
|
|
67
|
+
error::insufficient_seeds(seed_balance(user_storage, crop_type) >= 1);
|
|
68
|
+
|
|
69
|
+
// Deduct exactly 1 seed from the seed-specific resource
|
|
70
|
+
deduct_seeds(user_storage, crop_type, 1, ctx);
|
|
71
|
+
|
|
72
|
+
let now = sui::clock::timestamp_ms(clock);
|
|
73
|
+
let duration = crop_duration(crop_type);
|
|
74
|
+
// Store the yield amount — harvest will return this many crops
|
|
75
|
+
let harvest_count = crop_yield(crop_type);
|
|
76
|
+
farm_plot::set(user_storage, plot_id, crop_type, harvest_count, now, now + duration, ctx);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// Harvest a ready crop from farm plot `plot_id`.
|
|
80
|
+
/// Yields crops (not seeds) into the crop-specific resource.
|
|
81
|
+
public entry fun harvest(
|
|
82
|
+
dapp_storage: &DappStorage,
|
|
83
|
+
user_storage: &mut UserStorage,
|
|
84
|
+
plot_id: u8,
|
|
85
|
+
clock: &Clock,
|
|
86
|
+
ctx: &mut TxContext,
|
|
87
|
+
) {
|
|
88
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
89
|
+
error::not_registered(profile::has(user_storage));
|
|
90
|
+
error::plot_not_found(farm_plot::has(user_storage, plot_id));
|
|
91
|
+
|
|
92
|
+
let crop_type = farm_plot::get_crop_type(user_storage, plot_id);
|
|
93
|
+
error::plot_is_empty(crop_type != CROP_NONE);
|
|
94
|
+
|
|
95
|
+
let now = sui::clock::timestamp_ms(clock);
|
|
96
|
+
let harvest_at = farm_plot::get_harvest_at(user_storage, plot_id);
|
|
97
|
+
error::plot_not_ready(now >= harvest_at);
|
|
98
|
+
|
|
99
|
+
let base_count = farm_plot::get_count(user_storage, plot_id);
|
|
100
|
+
|
|
101
|
+
// Apply season bonus if the planted crop matches the active bonus crop.
|
|
102
|
+
let season_end = season_config::get_end_ms(dapp_storage);
|
|
103
|
+
let bonus_crop = season_config::get_bonus_crop(dapp_storage);
|
|
104
|
+
let season_id = season_config::get_season_id(dapp_storage);
|
|
105
|
+
let boosted = season_id > 0 && now < season_end && crop_type == bonus_crop;
|
|
106
|
+
let after_bonus = if (boosted) { base_count * SEASON_BONUS_PCT / 100 } else { base_count };
|
|
107
|
+
|
|
108
|
+
// Apply crow_damage debuff if active.
|
|
109
|
+
let final_count = if (crow_damage::has(user_storage)) {
|
|
110
|
+
let cd_expires = crow_damage::get_expires_at(user_storage);
|
|
111
|
+
if (now < cd_expires) {
|
|
112
|
+
let dmg_pct = (crow_damage::get_damage_pct(user_storage) as u64);
|
|
113
|
+
after_bonus * (100 - dmg_pct) / 100
|
|
114
|
+
} else {
|
|
115
|
+
after_bonus
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
after_bonus
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Yield goes into the crop resource (not seeds)
|
|
122
|
+
mint_crop(user_storage, crop_type, final_count, ctx);
|
|
123
|
+
|
|
124
|
+
// Track earnings for season leaderboard.
|
|
125
|
+
let gold_value = crop_gold_value(crop_type) * final_count;
|
|
126
|
+
if (season_stats::has(user_storage)) {
|
|
127
|
+
let prev = season_stats::get(user_storage);
|
|
128
|
+
season_stats::set(user_storage, prev + gold_value, ctx);
|
|
129
|
+
} else {
|
|
130
|
+
season_stats::set(user_storage, gold_value, ctx);
|
|
131
|
+
};
|
|
132
|
+
let prev_total = profile::get_total_earned(user_storage);
|
|
133
|
+
profile::set_total_earned(user_storage, prev_total + gold_value, ctx);
|
|
134
|
+
|
|
135
|
+
// Clear the plot.
|
|
136
|
+
farm_plot::set(user_storage, plot_id, CROP_NONE, 0, 0, 0, ctx);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
140
|
+
|
|
141
|
+
fun crop_duration(crop_type: u8): u64 {
|
|
142
|
+
if (crop_type == CROP_WHEAT) { WHEAT_MS }
|
|
143
|
+
else if (crop_type == CROP_CORN) { CORN_MS }
|
|
144
|
+
else if (crop_type == CROP_CARROT) { CARROT_MS }
|
|
145
|
+
else { PUMPKIN_MS }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
fun crop_yield(crop_type: u8): u64 {
|
|
149
|
+
if (crop_type == CROP_WHEAT) { WHEAT_YIELD }
|
|
150
|
+
else if (crop_type == CROP_CORN) { CORN_YIELD }
|
|
151
|
+
else if (crop_type == CROP_CARROT) { CARROT_YIELD }
|
|
152
|
+
else { PUMPKIN_YIELD }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
fun crop_gold_value(crop_type: u8): u64 {
|
|
156
|
+
if (crop_type == CROP_WHEAT) { 8 }
|
|
157
|
+
else if (crop_type == CROP_CORN) { 35 }
|
|
158
|
+
else if (crop_type == CROP_CARROT) { 120 }
|
|
159
|
+
else { 100 }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
fun seed_balance(user_storage: &UserStorage, crop_type: u8): u64 {
|
|
163
|
+
if (crop_type == CROP_WHEAT) { if (wheat_seed::has(user_storage)) { wheat_seed::get(user_storage) } else { 0 } }
|
|
164
|
+
else if (crop_type == CROP_CORN) { if (corn_seed::has(user_storage)) { corn_seed::get(user_storage) } else { 0 } }
|
|
165
|
+
else if (crop_type == CROP_CARROT) { if (carrot_seed::has(user_storage)) { carrot_seed::get(user_storage) } else { 0 } }
|
|
166
|
+
else { if (pumpkin_seed::has(user_storage)) { pumpkin_seed::get(user_storage) } else { 0 } }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
fun deduct_seeds(user_storage: &mut UserStorage, crop_type: u8, amount: u64, ctx: &mut TxContext) {
|
|
170
|
+
if (crop_type == CROP_WHEAT) { wheat_seed::sub(user_storage, amount, ctx) }
|
|
171
|
+
else if (crop_type == CROP_CORN) { corn_seed::sub(user_storage, amount, ctx) }
|
|
172
|
+
else if (crop_type == CROP_CARROT) { carrot_seed::sub(user_storage, amount, ctx) }
|
|
173
|
+
else { pumpkin_seed::sub(user_storage, amount, ctx) }
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fun mint_crop(user_storage: &mut UserStorage, crop_type: u8, amount: u64, ctx: &mut TxContext) {
|
|
177
|
+
if (crop_type == CROP_WHEAT) { wheat::add(user_storage, amount, ctx) }
|
|
178
|
+
else if (crop_type == CROP_CORN) { corn::add(user_storage, amount, ctx) }
|
|
179
|
+
else if (crop_type == CROP_CARROT) { carrot::add(user_storage, amount, ctx) }
|
|
180
|
+
else { pumpkin::add(user_storage, amount, ctx) }
|
|
181
|
+
}
|
|
182
|
+
}
|
package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/market_system.move
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/// Public entry wrappers for the listable crop market.
|
|
2
|
+
///
|
|
3
|
+
/// The framework's `take_fungible_record` (list) and `buy_fungible_record`
|
|
4
|
+
/// (buy) both enforce `ctx.sender() == canonical_owner(user_storage)`, so
|
|
5
|
+
/// session keys are rejected at the framework level — no extra check needed
|
|
6
|
+
/// here.
|
|
7
|
+
///
|
|
8
|
+
/// CoinType = 0x2::sui::SUI (price denominated in MIST)
|
|
9
|
+
module harvest::market_system {
|
|
10
|
+
use sui::sui::SUI;
|
|
11
|
+
use sui::coin::{Self, Coin};
|
|
12
|
+
use dubhe::dapp_service::{DappHub, DappStorage, UserStorage};
|
|
13
|
+
use dubhe::dapp_system;
|
|
14
|
+
use harvest::dapp_key::DappKey;
|
|
15
|
+
use harvest::migrate;
|
|
16
|
+
use harvest::wheat;
|
|
17
|
+
use harvest::corn;
|
|
18
|
+
use harvest::carrot;
|
|
19
|
+
use harvest::pumpkin;
|
|
20
|
+
|
|
21
|
+
const CROP_WHEAT: u8 = 1;
|
|
22
|
+
const CROP_CORN: u8 = 2;
|
|
23
|
+
const CROP_CARROT: u8 = 3;
|
|
24
|
+
const CROP_PUMPKIN: u8 = 4;
|
|
25
|
+
|
|
26
|
+
// ── List a crop batch for sale ─────────────────────────────────────────────
|
|
27
|
+
|
|
28
|
+
public entry fun list_wheat(
|
|
29
|
+
dapp_storage: &DappStorage,
|
|
30
|
+
user_storage: &mut UserStorage,
|
|
31
|
+
amount: u64,
|
|
32
|
+
price: u64, // total price in MIST
|
|
33
|
+
ctx: &mut TxContext,
|
|
34
|
+
) {
|
|
35
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
36
|
+
wheat::list<SUI>(user_storage, amount, price, std::option::none(), ctx);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public entry fun list_corn(
|
|
40
|
+
dapp_storage: &DappStorage,
|
|
41
|
+
user_storage: &mut UserStorage,
|
|
42
|
+
amount: u64,
|
|
43
|
+
price: u64,
|
|
44
|
+
ctx: &mut TxContext,
|
|
45
|
+
) {
|
|
46
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
47
|
+
corn::list<SUI>(user_storage, amount, price, std::option::none(), ctx);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public entry fun list_carrot(
|
|
51
|
+
dapp_storage: &DappStorage,
|
|
52
|
+
user_storage: &mut UserStorage,
|
|
53
|
+
amount: u64,
|
|
54
|
+
price: u64,
|
|
55
|
+
ctx: &mut TxContext,
|
|
56
|
+
) {
|
|
57
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
58
|
+
carrot::list<SUI>(user_storage, amount, price, std::option::none(), ctx);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public entry fun list_pumpkin(
|
|
62
|
+
dapp_storage: &DappStorage,
|
|
63
|
+
user_storage: &mut UserStorage,
|
|
64
|
+
amount: u64,
|
|
65
|
+
price: u64,
|
|
66
|
+
ctx: &mut TxContext,
|
|
67
|
+
) {
|
|
68
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
69
|
+
pumpkin::list<SUI>(user_storage, amount, price, std::option::none(), ctx);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── Buy a listing ──────────────────────────────────────────────────────────
|
|
73
|
+
// The `listing` argument is the shared Listing object.
|
|
74
|
+
// `payment` must be a Coin<SUI> with value >= listing.price.
|
|
75
|
+
// Any overpayment is returned to the buyer.
|
|
76
|
+
|
|
77
|
+
public entry fun buy_wheat(
|
|
78
|
+
dh: &DappHub,
|
|
79
|
+
dapp_storage: &mut DappStorage,
|
|
80
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
81
|
+
user_storage: &mut UserStorage,
|
|
82
|
+
payment: Coin<SUI>,
|
|
83
|
+
ctx: &mut TxContext,
|
|
84
|
+
) {
|
|
85
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
86
|
+
let change = wheat::buy<SUI>(dh, dapp_storage, listing, user_storage, payment, ctx);
|
|
87
|
+
return_change(change, ctx);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public entry fun buy_corn(
|
|
91
|
+
dh: &DappHub,
|
|
92
|
+
dapp_storage: &mut DappStorage,
|
|
93
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
94
|
+
user_storage: &mut UserStorage,
|
|
95
|
+
payment: Coin<SUI>,
|
|
96
|
+
ctx: &mut TxContext,
|
|
97
|
+
) {
|
|
98
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
99
|
+
let change = corn::buy<SUI>(dh, dapp_storage, listing, user_storage, payment, ctx);
|
|
100
|
+
return_change(change, ctx);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public entry fun buy_carrot(
|
|
104
|
+
dh: &DappHub,
|
|
105
|
+
dapp_storage: &mut DappStorage,
|
|
106
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
107
|
+
user_storage: &mut UserStorage,
|
|
108
|
+
payment: Coin<SUI>,
|
|
109
|
+
ctx: &mut TxContext,
|
|
110
|
+
) {
|
|
111
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
112
|
+
let change = carrot::buy<SUI>(dh, dapp_storage, listing, user_storage, payment, ctx);
|
|
113
|
+
return_change(change, ctx);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public entry fun buy_pumpkin(
|
|
117
|
+
dh: &DappHub,
|
|
118
|
+
dapp_storage: &mut DappStorage,
|
|
119
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
120
|
+
user_storage: &mut UserStorage,
|
|
121
|
+
payment: Coin<SUI>,
|
|
122
|
+
ctx: &mut TxContext,
|
|
123
|
+
) {
|
|
124
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
125
|
+
let change = pumpkin::buy<SUI>(dh, dapp_storage, listing, user_storage, payment, ctx);
|
|
126
|
+
return_change(change, ctx);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ── Cancel a listing (seller only) ────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
public entry fun cancel_wheat(
|
|
132
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
133
|
+
user_storage: &mut UserStorage,
|
|
134
|
+
ctx: &TxContext,
|
|
135
|
+
) {
|
|
136
|
+
wheat::cancel_listing<SUI>(listing, user_storage, ctx);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public entry fun cancel_corn(
|
|
140
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
141
|
+
user_storage: &mut UserStorage,
|
|
142
|
+
ctx: &TxContext,
|
|
143
|
+
) {
|
|
144
|
+
corn::cancel_listing<SUI>(listing, user_storage, ctx);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public entry fun cancel_carrot(
|
|
148
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
149
|
+
user_storage: &mut UserStorage,
|
|
150
|
+
ctx: &TxContext,
|
|
151
|
+
) {
|
|
152
|
+
carrot::cancel_listing<SUI>(listing, user_storage, ctx);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public entry fun cancel_pumpkin(
|
|
156
|
+
listing: dubhe::dapp_service::Listing<SUI>,
|
|
157
|
+
user_storage: &mut UserStorage,
|
|
158
|
+
ctx: &TxContext,
|
|
159
|
+
) {
|
|
160
|
+
pumpkin::cancel_listing<SUI>(listing, user_storage, ctx);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ── Helper ────────────────────────────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
fun return_change(change: Coin<SUI>, ctx: &TxContext) {
|
|
166
|
+
if (coin::value(&change) > 0) {
|
|
167
|
+
sui::transfer::public_transfer(change, ctx.sender());
|
|
168
|
+
} else {
|
|
169
|
+
coin::destroy_zero(change);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|