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/codegen/dapp_key.move
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::dapp_key {
|
|
7
|
+
use std::type_name;
|
|
8
|
+
use sui::address;
|
|
9
|
+
use std::ascii::String;
|
|
10
|
+
|
|
11
|
+
/// DappKey — package-level authorization token for this DApp.
|
|
12
|
+
///
|
|
13
|
+
/// SECURITY: `new()` is intentionally `public(package)`.
|
|
14
|
+
/// Only code compiled into this package can construct a DappKey instance.
|
|
15
|
+
/// All framework write functions (`set_record`, `set_field`,
|
|
16
|
+
/// `take_record`, `create_user_storage`, …) require `_auth: DappKey`
|
|
17
|
+
/// as proof that the call originated from inside this package — an
|
|
18
|
+
/// external PTB cannot fabricate that proof.
|
|
19
|
+
///
|
|
20
|
+
/// NEVER change `new()` to `public`, and never accept a DappKey
|
|
21
|
+
/// value as a parameter from an external caller. Either mistake removes
|
|
22
|
+
/// every package-level access guard, allowing any PTB to write arbitrary
|
|
23
|
+
/// user data or register UserStorages without going through the DApp's
|
|
24
|
+
/// own entry functions.
|
|
25
|
+
|
|
26
|
+
public struct DappKey has copy, drop {}
|
|
27
|
+
|
|
28
|
+
/// Constructs an authorization token. Callable only from within this package.
|
|
29
|
+
/// Pass the result as `_auth` to any framework function that requires it.
|
|
30
|
+
public(package) fun new(): DappKey {
|
|
31
|
+
DappKey {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public fun to_string(): String {
|
|
35
|
+
type_name::with_defining_ids<DappKey>().into_string()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public fun package_id(): address {
|
|
39
|
+
let package_id_str = type_name::with_defining_ids<DappKey>().address_string();
|
|
40
|
+
address::from_ascii_bytes(package_id_str.as_bytes())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public fun eq<DappKey1: copy + drop, DappKey2: copy + drop>(_: &DappKey1, _: &DappKey2): bool {
|
|
44
|
+
type_name::with_defining_ids<DappKey1>() == type_name::with_defining_ids<DappKey2>()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::crop_type {
|
|
7
|
+
use sui::bcs::{BCS, to_bytes, peel_enum_tag};
|
|
8
|
+
|
|
9
|
+
public enum CropType has copy, drop, store {
|
|
10
|
+
Carrot,Corn,None,Pumpkin,Wheat
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public fun new_carrot(): CropType {
|
|
14
|
+
CropType::Carrot
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public fun new_corn(): CropType {
|
|
18
|
+
CropType::Corn
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public fun new_none(): CropType {
|
|
22
|
+
CropType::None
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public fun new_pumpkin(): CropType {
|
|
26
|
+
CropType::Pumpkin
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public fun new_wheat(): CropType {
|
|
30
|
+
CropType::Wheat
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public fun encode(self: CropType): vector<u8> {
|
|
34
|
+
to_bytes(&self)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public fun decode(bytes: &mut BCS): CropType {
|
|
38
|
+
match(peel_enum_tag(bytes)) {
|
|
39
|
+
0 => CropType::Carrot,
|
|
40
|
+
1 => CropType::Corn,
|
|
41
|
+
2 => CropType::None,
|
|
42
|
+
3 => CropType::Pumpkin,
|
|
43
|
+
4 => CropType::Wheat,
|
|
44
|
+
_ => abort,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/egg_type.move
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::egg_type {
|
|
7
|
+
use sui::bcs::{BCS, to_bytes, peel_enum_tag};
|
|
8
|
+
|
|
9
|
+
public enum EggType has copy, drop, store {
|
|
10
|
+
Common,None,Rare,Seasonal
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public fun new_common(): EggType {
|
|
14
|
+
EggType::Common
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public fun new_none(): EggType {
|
|
18
|
+
EggType::None
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public fun new_rare(): EggType {
|
|
22
|
+
EggType::Rare
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public fun new_seasonal(): EggType {
|
|
26
|
+
EggType::Seasonal
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public fun encode(self: EggType): vector<u8> {
|
|
30
|
+
to_bytes(&self)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public fun decode(bytes: &mut BCS): EggType {
|
|
34
|
+
match(peel_enum_tag(bytes)) {
|
|
35
|
+
0 => EggType::Common,
|
|
36
|
+
1 => EggType::None,
|
|
37
|
+
2 => EggType::Rare,
|
|
38
|
+
3 => EggType::Seasonal,
|
|
39
|
+
_ => abort,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::pet_rarity {
|
|
7
|
+
use sui::bcs::{BCS, to_bytes, peel_enum_tag};
|
|
8
|
+
|
|
9
|
+
public enum PetRarity has copy, drop, store {
|
|
10
|
+
Common,Rare,Uncommon
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public fun new_common(): PetRarity {
|
|
14
|
+
PetRarity::Common
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public fun new_rare(): PetRarity {
|
|
18
|
+
PetRarity::Rare
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public fun new_uncommon(): PetRarity {
|
|
22
|
+
PetRarity::Uncommon
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public fun encode(self: PetRarity): vector<u8> {
|
|
26
|
+
to_bytes(&self)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public fun decode(bytes: &mut BCS): PetRarity {
|
|
30
|
+
match(peel_enum_tag(bytes)) {
|
|
31
|
+
0 => PetRarity::Common,
|
|
32
|
+
1 => PetRarity::Rare,
|
|
33
|
+
2 => PetRarity::Uncommon,
|
|
34
|
+
_ => abort,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::pet_species {
|
|
7
|
+
use sui::bcs::{BCS, to_bytes, peel_enum_tag};
|
|
8
|
+
|
|
9
|
+
public enum PetSpecies has copy, drop, store {
|
|
10
|
+
Bunny,Chick,Deer,Dragon,Fox,None
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public fun new_bunny(): PetSpecies {
|
|
14
|
+
PetSpecies::Bunny
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public fun new_chick(): PetSpecies {
|
|
18
|
+
PetSpecies::Chick
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public fun new_deer(): PetSpecies {
|
|
22
|
+
PetSpecies::Deer
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public fun new_dragon(): PetSpecies {
|
|
26
|
+
PetSpecies::Dragon
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public fun new_fox(): PetSpecies {
|
|
30
|
+
PetSpecies::Fox
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public fun new_none(): PetSpecies {
|
|
34
|
+
PetSpecies::None
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public fun encode(self: PetSpecies): vector<u8> {
|
|
38
|
+
to_bytes(&self)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public fun decode(bytes: &mut BCS): PetSpecies {
|
|
42
|
+
match(peel_enum_tag(bytes)) {
|
|
43
|
+
0 => PetSpecies::Bunny,
|
|
44
|
+
1 => PetSpecies::Chick,
|
|
45
|
+
2 => PetSpecies::Deer,
|
|
46
|
+
3 => PetSpecies::Dragon,
|
|
47
|
+
4 => PetSpecies::Fox,
|
|
48
|
+
5 => PetSpecies::None,
|
|
49
|
+
_ => abort,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::error {
|
|
7
|
+
#[error]
|
|
8
|
+
const EAlreadyRegistered: vector<u8> = b"Player already registered";
|
|
9
|
+
public fun already_registered(condition: bool) { assert!(condition, EAlreadyRegistered) }
|
|
10
|
+
|
|
11
|
+
#[error]
|
|
12
|
+
const ENotRegistered: vector<u8> = b"Player not registered";
|
|
13
|
+
public fun not_registered(condition: bool) { assert!(condition, ENotRegistered) }
|
|
14
|
+
|
|
15
|
+
#[error]
|
|
16
|
+
const EPlotNotFound: vector<u8> = b"Farm plot not found";
|
|
17
|
+
public fun plot_not_found(condition: bool) { assert!(condition, EPlotNotFound) }
|
|
18
|
+
|
|
19
|
+
#[error]
|
|
20
|
+
const EPlotAlreadyPlanted: vector<u8> = b"Farm plot already has a crop growing";
|
|
21
|
+
public fun plot_already_planted(condition: bool) { assert!(condition, EPlotAlreadyPlanted) }
|
|
22
|
+
|
|
23
|
+
#[error]
|
|
24
|
+
const EPlotNotReady: vector<u8> = b"Crop is not ready to harvest yet";
|
|
25
|
+
public fun plot_not_ready(condition: bool) { assert!(condition, EPlotNotReady) }
|
|
26
|
+
|
|
27
|
+
#[error]
|
|
28
|
+
const EPlotIsEmpty: vector<u8> = b"No crop planted on this plot";
|
|
29
|
+
public fun plot_is_empty(condition: bool) { assert!(condition, EPlotIsEmpty) }
|
|
30
|
+
|
|
31
|
+
#[error]
|
|
32
|
+
const EMaxPlotsReached: vector<u8> = b"Maximum farm plots already owned";
|
|
33
|
+
public fun max_plots_reached(condition: bool) { assert!(condition, EMaxPlotsReached) }
|
|
34
|
+
|
|
35
|
+
#[error]
|
|
36
|
+
const EInsufficientGold: vector<u8> = b"Not enough gold";
|
|
37
|
+
public fun insufficient_gold(condition: bool) { assert!(condition, EInsufficientGold) }
|
|
38
|
+
|
|
39
|
+
#[error]
|
|
40
|
+
const EInsufficientSeeds: vector<u8> = b"Not enough seeds to plant";
|
|
41
|
+
public fun insufficient_seeds(condition: bool) { assert!(condition, EInsufficientSeeds) }
|
|
42
|
+
|
|
43
|
+
#[error]
|
|
44
|
+
const EInsufficientCrops: vector<u8> = b"Not enough crops";
|
|
45
|
+
public fun insufficient_crops(condition: bool) { assert!(condition, EInsufficientCrops) }
|
|
46
|
+
|
|
47
|
+
#[error]
|
|
48
|
+
const ECrowNoCharges: vector<u8> = b"No crow charges remaining";
|
|
49
|
+
public fun crow_no_charges(condition: bool) { assert!(condition, ECrowNoCharges) }
|
|
50
|
+
|
|
51
|
+
#[error]
|
|
52
|
+
const ECrowTargetProtected: vector<u8> = b"Target farm is protected by a scarecrow";
|
|
53
|
+
public fun crow_target_protected(condition: bool) { assert!(condition, ECrowTargetProtected) }
|
|
54
|
+
|
|
55
|
+
#[error]
|
|
56
|
+
const EInvalidCropType: vector<u8> = b"Invalid crop type";
|
|
57
|
+
public fun invalid_crop_type(condition: bool) { assert!(condition, EInvalidCropType) }
|
|
58
|
+
|
|
59
|
+
#[error]
|
|
60
|
+
const ESeasonNotActive: vector<u8> = b"No active season";
|
|
61
|
+
public fun season_not_active(condition: bool) { assert!(condition, ESeasonNotActive) }
|
|
62
|
+
|
|
63
|
+
#[error]
|
|
64
|
+
const ENotAdmin: vector<u8> = b"Caller is not the DApp admin";
|
|
65
|
+
public fun not_admin(condition: bool) { assert!(condition, ENotAdmin) }
|
|
66
|
+
|
|
67
|
+
#[error]
|
|
68
|
+
const EHatchSlotBusy: vector<u8> = b"Already incubating an egg";
|
|
69
|
+
public fun hatch_slot_busy(condition: bool) { assert!(condition, EHatchSlotBusy) }
|
|
70
|
+
|
|
71
|
+
#[error]
|
|
72
|
+
const ENoEggIncubating: vector<u8> = b"No egg is currently incubating";
|
|
73
|
+
public fun no_egg_incubating(condition: bool) { assert!(condition, ENoEggIncubating) }
|
|
74
|
+
|
|
75
|
+
#[error]
|
|
76
|
+
const EEggNotReady: vector<u8> = b"Egg is not ready to hatch yet";
|
|
77
|
+
public fun egg_not_ready(condition: bool) { assert!(condition, EEggNotReady) }
|
|
78
|
+
|
|
79
|
+
#[error]
|
|
80
|
+
const EPetNotFound: vector<u8> = b"Pet not found in your ranch";
|
|
81
|
+
public fun pet_not_found(condition: bool) { assert!(condition, EPetNotFound) }
|
|
82
|
+
|
|
83
|
+
#[error]
|
|
84
|
+
const EPetSlotNotFound: vector<u8> = b"Pet slot does not exist";
|
|
85
|
+
public fun pet_slot_not_found(condition: bool) { assert!(condition, EPetSlotNotFound) }
|
|
86
|
+
|
|
87
|
+
#[error]
|
|
88
|
+
const EPetSlotOccupied: vector<u8> = b"Pet slot already has a pet";
|
|
89
|
+
public fun pet_slot_occupied(condition: bool) { assert!(condition, EPetSlotOccupied) }
|
|
90
|
+
|
|
91
|
+
#[error]
|
|
92
|
+
const EPetSlotEmpty: vector<u8> = b"No pet in that slot";
|
|
93
|
+
public fun pet_slot_empty(condition: bool) { assert!(condition, EPetSlotEmpty) }
|
|
94
|
+
|
|
95
|
+
#[error]
|
|
96
|
+
const EMaxPetSlotsReached: vector<u8> = b"Maximum pet slots already owned";
|
|
97
|
+
public fun max_pet_slots_reached(condition: bool) { assert!(condition, EMaxPetSlotsReached) }
|
|
98
|
+
|
|
99
|
+
#[error]
|
|
100
|
+
const EInsufficientEggs: vector<u8> = b"Not enough eggs of that type";
|
|
101
|
+
public fun insufficient_eggs(condition: bool) { assert!(condition, EInsufficientEggs) }
|
|
102
|
+
|
|
103
|
+
#[error]
|
|
104
|
+
const EInvalidEggType: vector<u8> = b"Invalid egg type";
|
|
105
|
+
public fun invalid_egg_type(condition: bool) { assert!(condition, EInvalidEggType) }
|
|
106
|
+
|
|
107
|
+
#[error]
|
|
108
|
+
const EInvalidPetSlot: vector<u8> = b"Invalid pet slot index";
|
|
109
|
+
public fun invalid_pet_slot(condition: bool) { assert!(condition, EInvalidPetSlot) }
|
|
110
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#[allow(lint(share_owned))]
|
|
2
|
+
module harvest::genesis {
|
|
3
|
+
use sui::clock::Clock;
|
|
4
|
+
use dubhe::dapp_service::{DappHub, DappStorage};
|
|
5
|
+
use harvest::dapp_key;
|
|
6
|
+
use dubhe::dapp_system;
|
|
7
|
+
use std::ascii::string;
|
|
8
|
+
|
|
9
|
+
// The one-shot guard is enforced inside dapp_system::create_dapp, which
|
|
10
|
+
// records the DappKey type in DappHub before returning DappStorage.
|
|
11
|
+
// genesis.move does not need to carry its own guard.
|
|
12
|
+
public fun run(dapp_hub: &mut DappHub, clock: &Clock, ctx: &mut TxContext) {
|
|
13
|
+
// create_dapp aborts with dapp_already_initialized_error on repeated calls.
|
|
14
|
+
let dapp_key = dapp_key::new();
|
|
15
|
+
let mut ds = dapp_system::create_dapp(dapp_key, dapp_hub, string(b"harvest"), string(b"Harvest - Full-chain casual farming game with light PvP"), 1, clock, ctx);
|
|
16
|
+
|
|
17
|
+
// Set up initial DApp state (e.g. default resource values).
|
|
18
|
+
harvest::deploy_hook::run(&mut ds, ctx);
|
|
19
|
+
|
|
20
|
+
// Share DappStorage so every transaction can access it.
|
|
21
|
+
transfer::public_share_object(ds);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Called during contract upgrades to register newly added resource tables
|
|
25
|
+
// and run any custom migration logic. `dubhe upgrade` rewrites the region
|
|
26
|
+
// between the separator comments; do not edit that block manually.
|
|
27
|
+
public(package) fun migrate(_dapp_hub: &mut DappHub, _dapp_storage: &mut DappStorage, _ctx: &mut TxContext) {
|
|
28
|
+
// ==========================================
|
|
29
|
+
// Add custom migration logic here (e.g. initialise new resource defaults).
|
|
30
|
+
// migrate_to_vN in migrate.move calls this function automatically.
|
|
31
|
+
// ==========================================
|
|
32
|
+
}
|
|
33
|
+
}
|
package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/init_test.move
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#[test_only]
|
|
2
|
+
|
|
3
|
+
module harvest::init_test {
|
|
4
|
+
use dubhe::dapp_system;
|
|
5
|
+
|
|
6
|
+
/// Create a DappHub for testing without sharing it.
|
|
7
|
+
/// Suitable for unit tests that need a DappHub context.
|
|
8
|
+
public fun create_dapp_hub_for_testing(ctx: &mut TxContext): dubhe::dapp_service::DappHub {
|
|
9
|
+
dapp_system::create_dapp_hub_for_testing(ctx)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/// Create a DappStorage for this DApp without sharing it.
|
|
13
|
+
/// Suitable for unit tests that exercise global-resource functions.
|
|
14
|
+
public fun create_dapp_storage_for_testing(ctx: &mut TxContext): dubhe::dapp_service::DappStorage {
|
|
15
|
+
dubhe::dapp_system::create_dapp_storage_for_testing<harvest::dapp_key::DappKey>(ctx)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// Create a UserStorage for `owner` without sharing it.
|
|
19
|
+
/// Suitable for unit tests that exercise user-level resource functions.
|
|
20
|
+
public fun create_user_storage_for_testing(owner: address, ctx: &mut TxContext): dubhe::dapp_service::UserStorage {
|
|
21
|
+
dubhe::dapp_system::create_user_storage_for_testing<harvest::dapp_key::DappKey>(owner, ctx)
|
|
22
|
+
}
|
|
23
|
+
}
|
package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/permits/world.move
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::world {
|
|
7
|
+
use dubhe::dapp_service::{Self, DappStorage};
|
|
8
|
+
use harvest::dapp_key;
|
|
9
|
+
use harvest::dapp_key::DappKey;
|
|
10
|
+
|
|
11
|
+
const PERMIT_TYPE: vector<u8> = b"world";
|
|
12
|
+
|
|
13
|
+
#[error]
|
|
14
|
+
const EPermitNotExpiredYet: vector<u8> = b"Scene permit is still active";
|
|
15
|
+
|
|
16
|
+
/// Phantom type that distinguishes this permit from others at compile time.
|
|
17
|
+
public struct World has copy, drop {}
|
|
18
|
+
|
|
19
|
+
public fun meta(permit: &dubhe::dapp_service::ScenePermit<World>): &dubhe::dapp_service::PermitMetadata {
|
|
20
|
+
dapp_service::scene_permit_meta(permit)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public fun is_active(permit: &dubhe::dapp_service::ScenePermit<World>, now_ms: u64): bool {
|
|
24
|
+
dapp_service::is_scene_active(dapp_service::scene_permit_meta(permit), now_ms)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public fun is_participant(permit: &dubhe::dapp_service::ScenePermit<World>, addr: address): bool {
|
|
28
|
+
dubhe::dapp_system::is_scene_permit_participant<World>(permit, addr)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public(package) fun new_world(
|
|
32
|
+
dapp_storage: &DappStorage,
|
|
33
|
+
participants: vector<address>,
|
|
34
|
+
expires_at: std::option::Option<u64>,
|
|
35
|
+
max_participants: std::option::Option<u64>,
|
|
36
|
+
ctx: &mut TxContext,
|
|
37
|
+
): dubhe::dapp_service::ScenePermit<World> {
|
|
38
|
+
dubhe::dapp_system::new_scene_permit<DappKey, World>(
|
|
39
|
+
dapp_key::new(), dapp_storage, PERMIT_TYPE, participants, expires_at, max_participants, ctx
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public(package) fun new_world_with_invitations(
|
|
44
|
+
dapp_storage: &DappStorage,
|
|
45
|
+
invitees: vector<address>,
|
|
46
|
+
invites_expire_at: std::option::Option<u64>,
|
|
47
|
+
scene_expires_at: std::option::Option<u64>,
|
|
48
|
+
max_participants: std::option::Option<u64>,
|
|
49
|
+
ctx: &mut TxContext,
|
|
50
|
+
): dubhe::dapp_service::ScenePermit<World> {
|
|
51
|
+
dubhe::dapp_system::new_scene_permit_with_invitations<DappKey, World>(
|
|
52
|
+
dapp_key::new(), dapp_storage, PERMIT_TYPE, invitees, invites_expire_at, scene_expires_at, max_participants, ctx
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public(package) fun share_world(permit: dubhe::dapp_service::ScenePermit<World>) {
|
|
57
|
+
dubhe::dapp_system::share_scene_permit<DappKey, World>(
|
|
58
|
+
dapp_key::new(), permit
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public(package) fun create_world(
|
|
63
|
+
dapp_storage: &DappStorage,
|
|
64
|
+
participants: vector<address>,
|
|
65
|
+
expires_at: std::option::Option<u64>,
|
|
66
|
+
max_participants: std::option::Option<u64>,
|
|
67
|
+
ctx: &mut TxContext,
|
|
68
|
+
) {
|
|
69
|
+
dubhe::dapp_system::create_and_share_scene_permit<DappKey, World>(
|
|
70
|
+
dapp_key::new(), dapp_storage, PERMIT_TYPE, participants, expires_at, max_participants, ctx
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public(package) fun create_world_with_invitations(
|
|
75
|
+
dapp_storage: &DappStorage,
|
|
76
|
+
invitees: vector<address>,
|
|
77
|
+
invites_expire_at: std::option::Option<u64>,
|
|
78
|
+
scene_expires_at: std::option::Option<u64>,
|
|
79
|
+
max_participants: std::option::Option<u64>,
|
|
80
|
+
ctx: &mut TxContext,
|
|
81
|
+
) {
|
|
82
|
+
dubhe::dapp_system::create_and_share_scene_permit_with_invitations<DappKey, World>(
|
|
83
|
+
dapp_key::new(), dapp_storage, PERMIT_TYPE, invitees, invites_expire_at, scene_expires_at, max_participants, ctx
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public(package) fun accept_world(
|
|
88
|
+
permit: &mut dubhe::dapp_service::ScenePermit<World>,
|
|
89
|
+
user_storage: &dubhe::dapp_service::UserStorage,
|
|
90
|
+
ctx: &TxContext,
|
|
91
|
+
) {
|
|
92
|
+
dubhe::dapp_system::accept_scene_permit_invitation<DappKey, World>(
|
|
93
|
+
dapp_key::new(), permit, user_storage, ctx
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public(package) fun join_world(
|
|
98
|
+
permit: &mut dubhe::dapp_service::ScenePermit<World>,
|
|
99
|
+
user_storage: &dubhe::dapp_service::UserStorage,
|
|
100
|
+
ctx: &TxContext,
|
|
101
|
+
) {
|
|
102
|
+
dubhe::dapp_system::join_scene_permit<DappKey, World>(dapp_key::new(), permit, user_storage, ctx);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public(package) fun leave_world(
|
|
106
|
+
permit: &mut dubhe::dapp_service::ScenePermit<World>,
|
|
107
|
+
user_storage: &dubhe::dapp_service::UserStorage,
|
|
108
|
+
ctx: &TxContext,
|
|
109
|
+
) {
|
|
110
|
+
dubhe::dapp_system::leave_scene_permit<DappKey, World>(dapp_key::new(), permit, user_storage, ctx);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public(package) fun expire_world(
|
|
114
|
+
permit: dubhe::dapp_service::ScenePermit<World>,
|
|
115
|
+
ctx: &TxContext,
|
|
116
|
+
) {
|
|
117
|
+
assert!(
|
|
118
|
+
!dapp_service::is_scene_active(dapp_service::scene_permit_meta(&permit), ctx.epoch_timestamp_ms()),
|
|
119
|
+
EPermitNotExpiredYet
|
|
120
|
+
);
|
|
121
|
+
dubhe::dapp_system::destroy_scene_permit<DappKey, World>(
|
|
122
|
+
dapp_key::new(), permit
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Copyright (c) Obelisk Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* Autogenerated file. Do not edit manually. */
|
|
5
|
+
|
|
6
|
+
module harvest::carrot {
|
|
7
|
+
use sui::bcs::{to_bytes};
|
|
8
|
+
use dubhe::dapp_service::{UserStorage, DappStorage};
|
|
9
|
+
use dubhe::dapp_system;
|
|
10
|
+
use harvest::dapp_key;
|
|
11
|
+
use harvest::dapp_key::DappKey;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const TABLE_NAME: vector<u8> = b"carrot";
|
|
15
|
+
const OFFCHAIN: bool = false;
|
|
16
|
+
|
|
17
|
+
public fun has(user_storage: &UserStorage): bool {
|
|
18
|
+
let mut key_tuple = vector::empty();
|
|
19
|
+
key_tuple.push_back(TABLE_NAME);
|
|
20
|
+
dapp_system::has_record<DappKey>(user_storage, key_tuple)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public fun ensure_has(user_storage: &UserStorage) {
|
|
24
|
+
let mut key_tuple = vector::empty();
|
|
25
|
+
key_tuple.push_back(TABLE_NAME);
|
|
26
|
+
dapp_system::ensure_has_record<DappKey>(user_storage, key_tuple)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public fun ensure_has_not(user_storage: &UserStorage) {
|
|
30
|
+
let mut key_tuple = vector::empty();
|
|
31
|
+
key_tuple.push_back(TABLE_NAME);
|
|
32
|
+
dapp_system::ensure_has_not_record<DappKey>(user_storage, key_tuple)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
public(package) fun delete(user_storage: &mut UserStorage, ctx: &TxContext) {
|
|
37
|
+
let mut key_tuple = vector::empty();
|
|
38
|
+
key_tuple.push_back(TABLE_NAME);
|
|
39
|
+
dapp_system::delete_record<DappKey>(dapp_key::new(), user_storage, key_tuple, vector[b"amount"], ctx);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public fun get(user_storage: &UserStorage): u64 {
|
|
43
|
+
let mut key_tuple = vector::empty();
|
|
44
|
+
key_tuple.push_back(TABLE_NAME);
|
|
45
|
+
let amount_raw = dapp_system::get_field<DappKey>(user_storage, key_tuple, b"amount");
|
|
46
|
+
let mut amount_bcs = sui::bcs::new(amount_raw);
|
|
47
|
+
let value = sui::bcs::peel_u64(&mut amount_bcs);
|
|
48
|
+
value
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public(package) fun set(user_storage: &mut UserStorage, value: u64, ctx: &mut TxContext) {
|
|
52
|
+
let mut key_tuple = vector::empty();
|
|
53
|
+
key_tuple.push_back(TABLE_NAME);
|
|
54
|
+
let field_names = vector[b"amount"];
|
|
55
|
+
let value_tuple = encode(value);
|
|
56
|
+
dapp_system::set_record<DappKey>(dapp_key::new(), user_storage, key_tuple, field_names, value_tuple, OFFCHAIN, ctx);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public fun encode(value: u64): vector<vector<u8>> {
|
|
60
|
+
let mut value_tuple = vector::empty();
|
|
61
|
+
value_tuple.push_back(to_bytes(&value));
|
|
62
|
+
value_tuple
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// ─── fungible add / sub ─────────────────────────────────────────────
|
|
67
|
+
#[error]
|
|
68
|
+
const EInsufficientAmount: vector<u8> = b"Insufficient amount";
|
|
69
|
+
|
|
70
|
+
public(package) fun add(user_storage: &mut UserStorage, amount: u64, ctx: &mut TxContext) {
|
|
71
|
+
let current = if (has(user_storage)) { get(user_storage) } else { 0 };
|
|
72
|
+
set(user_storage, current + amount, ctx);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public(package) fun sub(user_storage: &mut UserStorage, amount: u64, ctx: &mut TxContext) {
|
|
76
|
+
let current = get(user_storage);
|
|
77
|
+
assert!(current >= amount, EInsufficientAmount);
|
|
78
|
+
set(user_storage, current - amount, ctx);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ─── listable: market protocol (fungible) ──────────────────────────
|
|
82
|
+
// Package-level helpers: call these from your system functions.
|
|
83
|
+
// Add pause checks, access control, and custom logic there.
|
|
84
|
+
public(package) fun list<CoinType>(
|
|
85
|
+
user_storage: &mut UserStorage,
|
|
86
|
+
amount: u64,
|
|
87
|
+
price: u64,
|
|
88
|
+
listed_until: std::option::Option<u64>,
|
|
89
|
+
ctx: &mut TxContext,
|
|
90
|
+
) {
|
|
91
|
+
dubhe::dapp_system::take_fungible_record<DappKey, CoinType>(
|
|
92
|
+
dapp_key::new(),
|
|
93
|
+
user_storage,
|
|
94
|
+
b"carrot",
|
|
95
|
+
{ let mut k = vector::empty(); k.push_back(TABLE_NAME); k },
|
|
96
|
+
b"amount",
|
|
97
|
+
amount,
|
|
98
|
+
price,
|
|
99
|
+
listed_until,
|
|
100
|
+
ctx,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public(package) fun buy<CoinType>(
|
|
105
|
+
dh: &dubhe::dapp_service::DappHub,
|
|
106
|
+
dapp_storage: &mut DappStorage,
|
|
107
|
+
listing: dubhe::dapp_service::Listing<CoinType>,
|
|
108
|
+
user_storage: &mut UserStorage,
|
|
109
|
+
payment: sui::coin::Coin<CoinType>,
|
|
110
|
+
ctx: &mut TxContext,
|
|
111
|
+
): sui::coin::Coin<CoinType> {
|
|
112
|
+
dubhe::dapp_system::buy_fungible_record<DappKey, CoinType>(
|
|
113
|
+
dapp_key::new(), dh, dapp_storage, listing, user_storage, payment, ctx
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public(package) fun cancel_listing<CoinType>(
|
|
118
|
+
listing: dubhe::dapp_service::Listing<CoinType>,
|
|
119
|
+
user_storage: &mut UserStorage,
|
|
120
|
+
ctx: &TxContext,
|
|
121
|
+
) {
|
|
122
|
+
dubhe::dapp_system::cancel_fungible_listing<DappKey, CoinType>(
|
|
123
|
+
dapp_key::new(), listing, user_storage, ctx
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public(package) fun expire_listing<CoinType>(
|
|
128
|
+
listing: dubhe::dapp_service::Listing<CoinType>,
|
|
129
|
+
user_storage: &mut UserStorage,
|
|
130
|
+
ctx: &TxContext,
|
|
131
|
+
) {
|
|
132
|
+
dubhe::dapp_system::expire_fungible_listing<DappKey, CoinType>(
|
|
133
|
+
dapp_key::new(), listing, user_storage, ctx
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|