create-mud 2.2.17-f52b1476f04ce0be68691e3b021a81e0fb9cce99 → 2.2.17-f88e48e47ceb4a29a3862a3f3b85891490952f0e
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/README.md +4 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +2 -9
- package/dist/cli.js.map +1 -1
- package/{templates → dist/templates}/react/packages/client/src/mud/Synced.tsx +1 -1
- package/{templates → dist/templates}/react/packages/contracts/mud.config.ts +7 -0
- package/{templates → dist/templates}/react/packages/contracts/test/MoveTest.t.sol +2 -0
- package/{templates/react-ecs → dist/templates/react}/packages/contracts/test/WorldTest.t.sol +5 -0
- package/{templates/react → dist/templates/react-ecs}/package.json +2 -1
- package/{templates → dist/templates}/react-ecs/packages/client/package.json +9 -16
- package/dist/templates/react-ecs/packages/client/src/App.tsx +29 -0
- package/dist/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts +51 -0
- package/dist/templates/react-ecs/packages/client/src/mud/getNetworkConfig.ts +77 -0
- package/{templates/react → dist/templates/threejs}/packages/client/index.html +2 -2
- package/dist/templates/threejs/packages/client/src/MUDContext.tsx +21 -0
- package/dist/templates/threejs/packages/client/src/index.tsx +34 -0
- package/{templates/react → dist/templates/threejs}/packages/client/vite.config.ts +7 -2
- package/{templates/react-ecs → dist/templates/threejs}/packages/contracts/.env +1 -1
- package/dist/templates/vanilla/gitignore +7 -0
- package/dist/templates/vanilla/mprocs.yaml +13 -0
- package/dist/templates/vanilla/packages/client/gitignore +3 -0
- package/dist/templates/vanilla/packages/client/src/mud/createClientComponents.ts +21 -0
- package/dist/templates/vanilla/packages/client/src/mud/setup.ts +21 -0
- package/dist/templates/vanilla/packages/client/src/mud/setupNetwork.ts +106 -0
- package/dist/templates/vanilla/packages/client/src/mud/supportedChains.ts +20 -0
- package/dist/templates/vanilla/packages/client/src/mud/world.ts +3 -0
- package/{templates/react → dist/templates/vanilla}/packages/client/tsconfig.json +1 -1
- package/dist/templates/vanilla/packages/contracts/.env +11 -0
- package/dist/templates/vanilla/packages/contracts/gitignore +9 -0
- package/dist/templates/vanilla/packages/contracts/mud.config.ts +13 -0
- package/{templates/react → dist/templates/vanilla}/packages/contracts/package.json +0 -1
- package/{templates/react → dist/templates/vanilla}/packages/contracts/script/PostDeploy.s.sol +5 -1
- package/{templates/react/packages/contracts/src/codegen/common.sol → dist/templates/vanilla/packages/contracts/src/codegen/index.sol} +1 -6
- package/{templates/react-ecs/packages/contracts/src/codegen/tables/EntityCount.sol → dist/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol} +35 -35
- package/dist/templates/vanilla/packages/contracts/src/codegen/world/IIncrementSystem.sol +13 -0
- package/dist/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol +16 -0
- package/dist/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol +14 -0
- package/dist/templates/vanilla/packages/contracts/test/CounterTest.t.sol +31 -0
- package/dist/templates/vanilla/packages/contracts/worlds.json +5 -0
- package/package.json +11 -17
- package/bin/cli.js +0 -4
- package/templates/react/.gitignore_ +0 -16
- package/templates/react/mprocs.yaml +0 -21
- package/templates/react/packages/client/.gitignore_ +0 -1
- package/templates/react/packages/client/postcss.config.cjs +0 -6
- package/templates/react/packages/client/src/game/useKeyboardMovement.ts +0 -26
- package/templates/react/packages/client/src/index.tsx +0 -19
- package/templates/react/packages/client/src/mud/Explorer.tsx +0 -32
- package/templates/react/packages/client/src/mud/useWorldContract.ts +0 -44
- package/templates/react/packages/client/src/ui/AsyncButton.tsx +0 -41
- package/templates/react/packages/client/src/ui/ErrorFallback.tsx +0 -58
- package/templates/react/packages/client/src/ui/icons/ArrowDownIcon.tsx +0 -22
- package/templates/react/packages/client/src/ui/icons/MUDIcon.tsx +0 -25
- package/templates/react/packages/client/src/wagmiConfig.ts +0 -49
- package/templates/react/packages/client/tailwind.config.ts +0 -10
- package/templates/react/packages/contracts/.env +0 -11
- package/templates/react/packages/contracts/.gitignore_ +0 -13
- package/templates/react/packages/contracts/test/WorldTest.t.sol +0 -16
- package/templates/react/packages/contracts/worlds.json +0 -5
- package/templates/react-ecs/packages/client/src/App.tsx +0 -74
- package/templates/react-ecs/packages/client/src/Providers.tsx +0 -29
- package/templates/react-ecs/packages/client/src/common.ts +0 -27
- package/templates/react-ecs/packages/client/src/game/GameMap.tsx +0 -112
- package/templates/react-ecs/packages/client/src/mud/Synced.tsx +0 -14
- package/templates/react-ecs/packages/client/src/mud/recs.ts +0 -6
- package/templates/react-ecs/packages/client/src/mud/useSyncStatus.ts +0 -17
- package/templates/react-ecs/packages/contracts/mud.config.ts +0 -18
- package/templates/react-ecs/packages/contracts/out/IWorld.sol/IWorld.abi.json +0 -2039
- package/templates/react-ecs/packages/contracts/src/Entity.sol +0 -20
- package/templates/react-ecs/packages/contracts/src/MoveSystem.sol +0 -30
- package/templates/react-ecs/packages/contracts/src/SpawnSystem.sol +0 -18
- package/templates/react-ecs/packages/contracts/src/codegen/index.sol +0 -8
- package/templates/react-ecs/packages/contracts/src/codegen/tables/Owner.sol +0 -202
- package/templates/react-ecs/packages/contracts/src/codegen/tables/Position.sol +0 -321
- package/templates/react-ecs/packages/contracts/src/codegen/world/IMoveSystem.sol +0 -16
- package/templates/react-ecs/packages/contracts/src/codegen/world/ISpawnSystem.sol +0 -15
- package/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol +0 -17
- package/templates/react-ecs/packages/contracts/src/createEntity.sol +0 -11
- package/templates/react-ecs/packages/contracts/test/MoveTest.t.sol +0 -39
- /package/{templates → dist/templates}/phaser/.eslintrc +0 -0
- /package/{templates → dist/templates}/phaser/.gitattributes +0 -0
- /package/{templates → dist/templates}/phaser/.vscode/extensions.json +0 -0
- /package/{templates → dist/templates}/phaser/.vscode/settings.json +0 -0
- /package/{templates/phaser/.gitignore_ → dist/templates/phaser/gitignore} +0 -0
- /package/{templates → dist/templates}/phaser/mprocs.yaml +0 -0
- /package/{templates → dist/templates}/phaser/package.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/README.md +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/config-sprites.json +0 -0
- /package/{templates/phaser/packages/art/.gitignore_ → dist/templates/phaser/packages/art/gitignore} +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/package.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/scripts/cli.mjs +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/scripts/export-tiled-types.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/attack/0.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/attack/1.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/attack/2.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/attack/3.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/attack/4.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/attack/5.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/death/0.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/death/1.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/death/2.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/idle/0.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/idle/1.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/idle/2.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/sprites/golem/idle/3.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/tilesets/images/world.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/art/tilesets/world.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/.env +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/.eslintrc +0 -0
- /package/{templates/phaser/packages/client/.gitignore_ → dist/templates/phaser/packages/client/gitignore} +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/index.html +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/package.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/public/assets/atlases/atlas.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/public/assets/atlases/atlas.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/public/assets/tilesets/world.png +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/artTypes/world.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/index.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/network/createNetworkLayer.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/phaser/configurePhaser.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/phaser/constants.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/phaser/createPhaserLayer.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/phaser/systems/createCamera.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/phaser/systems/createMapSystem.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/phaser/systems/index.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/layers/phaser/systems/registerSystems.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/mud/createClientComponents.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/mud/createSystemCalls.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/mud/getNetworkConfig.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/mud/setup.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/mud/setupNetwork.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/mud/supportedChains.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/mud/world.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/store.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/App.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/LoadingScreen/BootScreen.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/LoadingScreen/LoadingBar.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/LoadingScreen/LoadingScreen.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/LoadingScreen/index.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/PhaserLayer.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/UIRoot.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/Wrapper.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/hooks/useNetworkLayer.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/hooks/usePromiseValue.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/theme/ClickWrapper.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/src/ui/theme/SpriteImage.tsx +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/tsconfig.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/client/vite.config.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/.env +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/.prettierrc +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/.solhint.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/foundry.toml +0 -0
- /package/{templates/phaser/packages/contracts/.gitignore_ → dist/templates/phaser/packages/contracts/gitignore} +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/mud.config.ts +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/package.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/remappings.txt +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/script/PostDeploy.s.sol +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/src/codegen/index.sol +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/src/codegen/tables/Counter.sol +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/src/codegen/world/IIncrementSystem.sol +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/src/systems/IncrementSystem.sol +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/test/CounterTest.t.sol +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/tsconfig.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/worlds.json +0 -0
- /package/{templates → dist/templates}/phaser/packages/contracts/worlds.json.d.ts +0 -0
- /package/{templates → dist/templates}/phaser/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/phaser/tsconfig.json +0 -0
- /package/{templates → dist/templates}/react/.eslintrc +0 -0
- /package/{templates → dist/templates}/react/.gitattributes +0 -0
- /package/{templates → dist/templates}/react/.vscode/extensions.json +0 -0
- /package/{templates → dist/templates}/react/.vscode/settings.json +0 -0
- /package/{templates/react-ecs/.gitignore_ → dist/templates/react/gitignore} +0 -0
- /package/{templates/react-ecs → dist/templates/react}/mprocs.yaml +0 -0
- /package/{templates/react-ecs → dist/templates/react}/package.json +0 -0
- /package/{templates → dist/templates}/react/packages/client/.env +0 -0
- /package/{templates → dist/templates}/react/packages/client/.eslintrc +0 -0
- /package/{templates/react-ecs/packages/client/.gitignore_ → dist/templates/react/packages/client/gitignore} +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/index.html +0 -0
- /package/{templates → dist/templates}/react/packages/client/package.json +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/postcss.config.cjs +0 -0
- /package/{templates → dist/templates}/react/packages/client/src/App.tsx +0 -0
- /package/{templates → dist/templates}/react/packages/client/src/Providers.tsx +0 -0
- /package/{templates → dist/templates}/react/packages/client/src/common.ts +0 -0
- /package/{templates → dist/templates}/react/packages/client/src/game/GameMap.tsx +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/game/useKeyboardMovement.ts +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/index.tsx +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/mud/Explorer.tsx +0 -0
- /package/{templates → dist/templates}/react/packages/client/src/mud/stash.ts +0 -0
- /package/{templates → dist/templates}/react/packages/client/src/mud/useSyncStatus.ts +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/mud/useWorldContract.ts +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/ui/AsyncButton.tsx +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/ui/ErrorFallback.tsx +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/ui/icons/ArrowDownIcon.tsx +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/ui/icons/MUDIcon.tsx +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/src/wagmiConfig.ts +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/tailwind.config.ts +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/tsconfig.json +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/client/vite.config.ts +0 -0
- /package/{templates/vanilla → dist/templates/react}/packages/contracts/.env +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/.prettierrc +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/.solhint.json +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/foundry.toml +0 -0
- /package/{templates/react-ecs/packages/contracts/.gitignore_ → dist/templates/react/packages/contracts/gitignore} +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/out/IWorld.sol/IWorld.abi.json +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/contracts/package.json +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/remappings.txt +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/contracts/script/PostDeploy.s.sol +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/src/MoveSystem.sol +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/contracts/src/codegen/common.sol +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/src/codegen/index.sol +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/src/codegen/tables/Position.sol +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/src/codegen/world/IMoveSystem.sol +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/tsconfig.json +0 -0
- /package/{templates/react-ecs → dist/templates/react}/packages/contracts/worlds.json +0 -0
- /package/{templates → dist/templates}/react/packages/contracts/worlds.json.d.ts +0 -0
- /package/{templates → dist/templates}/react/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/react/tsconfig.json +0 -0
- /package/{templates → dist/templates}/react-ecs/.eslintrc +0 -0
- /package/{templates → dist/templates}/react-ecs/.gitattributes +0 -0
- /package/{templates → dist/templates}/react-ecs/.vscode/extensions.json +0 -0
- /package/{templates → dist/templates}/react-ecs/.vscode/settings.json +0 -0
- /package/{templates/threejs/.gitignore_ → dist/templates/react-ecs/gitignore} +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/mprocs.yaml +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/client/.env +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/client/.eslintrc +0 -0
- /package/{templates/threejs/packages/client/.gitignore_ → dist/templates/react-ecs/packages/client/gitignore} +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/index.html +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/src/MUDContext.tsx +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/src/index.tsx +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/src/mud/createClientComponents.ts +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/client/src/mud/setup.ts +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/client/src/mud/setupNetwork.ts +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/src/mud/supportedChains.ts +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/src/mud/world.ts +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/tsconfig.json +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/client/vite.config.ts +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/contracts/.env +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/contracts/.prettierrc +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/contracts/.solhint.json +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/contracts/foundry.toml +0 -0
- /package/{templates/threejs/packages/contracts/.gitignore_ → dist/templates/react-ecs/packages/contracts/gitignore} +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/mud.config.ts +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/package.json +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/contracts/remappings.txt +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/script/PostDeploy.s.sol +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/src/codegen/index.sol +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/src/codegen/tables/Counter.sol +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/src/codegen/world/IIncrementSystem.sol +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/src/systems/IncrementSystem.sol +0 -0
- /package/{templates/vanilla → dist/templates/react-ecs}/packages/contracts/test/CounterTest.t.sol +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/contracts/tsconfig.json +0 -0
- /package/{templates/threejs → dist/templates/react-ecs}/packages/contracts/worlds.json +0 -0
- /package/{templates → dist/templates}/react-ecs/packages/contracts/worlds.json.d.ts +0 -0
- /package/{templates → dist/templates}/react-ecs/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/react-ecs/tsconfig.json +0 -0
- /package/{templates → dist/templates}/threejs/.eslintrc +0 -0
- /package/{templates → dist/templates}/threejs/.gitattributes +0 -0
- /package/{templates → dist/templates}/threejs/.vscode/extensions.json +0 -0
- /package/{templates → dist/templates}/threejs/.vscode/settings.json +0 -0
- /package/{templates/vanilla/.gitignore_ → dist/templates/threejs/gitignore} +0 -0
- /package/{templates/vanilla → dist/templates/threejs}/mprocs.yaml +0 -0
- /package/{templates → dist/templates}/threejs/package.json +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/.env +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/.eslintrc +0 -0
- /package/{templates/vanilla/packages/client/.gitignore_ → dist/templates/threejs/packages/client/gitignore} +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/package.json +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/src/App.tsx +0 -0
- /package/{templates/vanilla → dist/templates/threejs}/packages/client/src/mud/createClientComponents.ts +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/src/mud/createSystemCalls.ts +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/src/mud/getNetworkConfig.ts +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/src/mud/setup.ts +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/src/mud/setupNetwork.ts +0 -0
- /package/{templates/vanilla → dist/templates/threejs}/packages/client/src/mud/supportedChains.ts +0 -0
- /package/{templates/vanilla → dist/templates/threejs}/packages/client/src/mud/world.ts +0 -0
- /package/{templates → dist/templates}/threejs/packages/client/src/useKeyboardMovement.ts +0 -0
- /package/{templates/vanilla → dist/templates/threejs}/packages/client/tsconfig.json +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/.prettierrc +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/.solhint.json +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/foundry.toml +0 -0
- /package/{templates/vanilla/packages/contracts/.gitignore_ → dist/templates/threejs/packages/contracts/gitignore} +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/mud.config.ts +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/package.json +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/remappings.txt +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/src/codegen/index.sol +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/src/codegen/tables/Position.sol +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/src/codegen/world/IMoveSystem.sol +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/src/codegen/world/IWorld.sol +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/src/systems/MoveSystem.sol +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/test/WorldTest.t.sol +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/tsconfig.json +0 -0
- /package/{templates/vanilla → dist/templates/threejs}/packages/contracts/worlds.json +0 -0
- /package/{templates → dist/templates}/threejs/packages/contracts/worlds.json.d.ts +0 -0
- /package/{templates → dist/templates}/threejs/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/threejs/tsconfig.json +0 -0
- /package/{templates → dist/templates}/vanilla/.eslintrc +0 -0
- /package/{templates → dist/templates}/vanilla/.gitattributes +0 -0
- /package/{templates → dist/templates}/vanilla/.vscode/extensions.json +0 -0
- /package/{templates → dist/templates}/vanilla/.vscode/settings.json +0 -0
- /package/{templates → dist/templates}/vanilla/package.json +0 -0
- /package/{templates → dist/templates}/vanilla/packages/client/.env +0 -0
- /package/{templates → dist/templates}/vanilla/packages/client/index.html +0 -0
- /package/{templates → dist/templates}/vanilla/packages/client/package.json +0 -0
- /package/{templates → dist/templates}/vanilla/packages/client/src/index.ts +0 -0
- /package/{templates → dist/templates}/vanilla/packages/client/src/mud/createSystemCalls.ts +0 -0
- /package/{templates → dist/templates}/vanilla/packages/client/src/mud/getNetworkConfig.ts +0 -0
- /package/{templates → dist/templates}/vanilla/packages/client/vite.config.ts +0 -0
- /package/{templates → dist/templates}/vanilla/packages/contracts/.prettierrc +0 -0
- /package/{templates → dist/templates}/vanilla/packages/contracts/.solhint.json +0 -0
- /package/{templates → dist/templates}/vanilla/packages/contracts/foundry.toml +0 -0
- /package/{templates → dist/templates}/vanilla/packages/contracts/remappings.txt +0 -0
- /package/{templates → dist/templates}/vanilla/packages/contracts/tsconfig.json +0 -0
- /package/{templates → dist/templates}/vanilla/packages/contracts/worlds.json.d.ts +0 -0
- /package/{templates → dist/templates}/vanilla/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/vanilla/tsconfig.json +0 -0
package/README.md
CHANGED
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
cd ${e.name}
|
|
5
|
-
pnpm install
|
|
6
|
-
pnpm dev
|
|
7
|
-
|
|
8
|
-
Have fun! For more info, check the docs at https://mud.dev/
|
|
9
|
-
`)})}w();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var l=Object.create;var p=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var h=(e,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of m(t))!u.call(e,r)&&r!==s&&p(e,r,{get:()=>t[r],enumerable:!(a=o(t,r))||a.enumerable});return e};var j=(e,t,s)=>(s=e!=null?l(d(e)):{},h(t||!e||!e.__esModule?p(s,"default",{value:e,enumerable:!0}):s,e));var i=require("create-create-app"),n=j(require("path"));var c={name:"create-mud",version:"2.2.17-f88e48e47ceb4a29a3862a3f3b85891490952f0e",description:"Create a new MUD project",license:"MIT",author:"Lattice <mud@lattice.xyz>",bin:"dist/cli.js",files:["dist"],scripts:{build:"pnpm run build:js","build:js":"tsup && tsx ./scripts/copy-templates.ts",clean:"pnpm run clean:js","clean:js":"shx rm -rf dist",dev:"tsup --watch",prepublishOnly:"npm run clean && npm run build",test:"pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs","test:ci":"pnpm run test","test:phaser":"dist/cli.js test-project --template phaser && shx rm -rf test-project","test:react":"dist/cli.js test-project --template react && shx rm -rf test-project","test:react-ecs":"dist/cli.js test-project --template react-ecs && shx rm -rf test-project","test:threejs":"dist/cli.js test-project --template threejs && shx rm -rf test-project","test:vanilla":"dist/cli.js test-project --template vanilla && shx rm -rf test-project"},dependencies:{"create-create-app":"git+https://github.com/holic/create-create-app#74376c59b48a04aabbe94d9cacfe9cb1cecccd63"},devDependencies:{execa:"^7.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org"}};var b=n.default.resolve(__dirname,"..","dist","templates");(0,i.create)("create-mud",{templateRoot:b,defaultTemplate:"vanilla",defaultPackageManager:"pnpm",promptForDescription:!1,promptForAuthor:!1,promptForEmail:!1,promptForLicense:!1,promptForTemplate:!0,caveat:({answers:e,packageManager:t})=>`Done! Play in the MUD with \`cd ${e.name}\` and \`${t} run dev\``,extra:{"mud-version":{type:"input",describe:"The version of MUD packages to use, defaults to latest",default:c.version}}});
|
|
10
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\nimport { create } from \"create-create-app\";\nimport path from \"node:path\";\nimport packageJson from \"../package.json\";\n\nconst templateRoot = path.resolve(__dirname, \"..\", \"dist\", \"templates\");\n\n// See https://github.com/uetchy/create-create-app/blob/master/README.md for other options.\ncreate(\"create-mud\", {\n templateRoot,\n defaultTemplate: \"vanilla\",\n // templates use pnpm workspaces, so default to that for now\n // not sure if it's worth trying to support multiple kinds of package managers for monorepos, given the tooling is so different\n defaultPackageManager: \"pnpm\",\n promptForDescription: false,\n promptForAuthor: false,\n promptForEmail: false,\n promptForLicense: false,\n promptForTemplate: true,\n caveat: ({ answers, packageManager }) =>\n `Done! Play in the MUD with \\`cd ${answers.name}\\` and \\`${packageManager} run dev\\``,\n extra: {\n \"mud-version\": {\n type: \"input\",\n describe: \"The version of MUD packages to use, defaults to latest\",\n default: packageJson.version,\n },\n },\n});\n","{\n \"name\": \"create-mud\",\n \"version\": \"2.2.17-f88e48e47ceb4a29a3862a3f3b85891490952f0e\",\n \"description\": \"Create a new MUD project\",\n \"license\": \"MIT\",\n \"author\": \"Lattice <mud@lattice.xyz>\",\n \"bin\": \"dist/cli.js\",\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"pnpm run build:js\",\n \"build:js\": \"tsup && tsx ./scripts/copy-templates.ts\",\n \"clean\": \"pnpm run clean:js\",\n \"clean:js\": \"shx rm -rf dist\",\n \"dev\": \"tsup --watch\",\n \"prepublishOnly\": \"npm run clean && npm run build\",\n \"test\": \"pnpm run test:vanilla && pnpm run test:react && pnpm run test:react-ecs && pnpm run test:phaser && pnpm run test:threejs\",\n \"test:ci\": \"pnpm run test\",\n \"test:phaser\": \"dist/cli.js test-project --template phaser && shx rm -rf test-project\",\n \"test:react\": \"dist/cli.js test-project --template react && shx rm -rf test-project\",\n \"test:react-ecs\": \"dist/cli.js test-project --template react-ecs && shx rm -rf test-project\",\n \"test:threejs\": \"dist/cli.js test-project --template threejs && shx rm -rf test-project\",\n \"test:vanilla\": \"dist/cli.js test-project --template vanilla && shx rm -rf test-project\"\n },\n \"dependencies\": {\n \"create-create-app\": \"git+https://github.com/holic/create-create-app#74376c59b48a04aabbe94d9cacfe9cb1cecccd63\"\n },\n \"devDependencies\": {\n \"execa\": \"^7.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org\"\n }\n}\n"],"mappings":";wdACA,IAAAA,EAAuB,6BACvBC,EAAiB,mBCFjB,IAAAC,EAAA,CACE,KAAQ,aACR,QAAW,kDACX,YAAe,2BACf,QAAW,MACX,OAAU,4BACV,IAAO,cACP,MAAS,CACP,MACF,EACA,QAAW,CACT,MAAS,oBACT,WAAY,0CACZ,MAAS,oBACT,WAAY,kBACZ,IAAO,eACP,eAAkB,iCAClB,KAAQ,2HACR,UAAW,gBACX,cAAe,wEACf,aAAc,uEACd,iBAAkB,2EAClB,eAAgB,yEAChB,eAAgB,wEAClB,EACA,aAAgB,CACd,oBAAqB,yFACvB,EACA,gBAAmB,CACjB,MAAS,QACX,EACA,cAAiB,CACf,OAAU,SACV,SAAY,4BACd,CACF,ED9BA,IAAMC,EAAe,EAAAC,QAAK,QAAQ,UAAW,KAAM,OAAQ,WAAW,KAGtE,UAAO,aAAc,CACnB,aAAAD,EACA,gBAAiB,UAGjB,sBAAuB,OACvB,qBAAsB,GACtB,gBAAiB,GACjB,eAAgB,GAChB,iBAAkB,GAClB,kBAAmB,GACnB,OAAQ,CAAC,CAAE,QAAAE,EAAS,eAAAC,CAAe,IACjC,mCAAmCD,EAAQ,IAAI,YAAYC,CAAc,aAC3E,MAAO,CACL,cAAe,CACb,KAAM,QACN,SAAU,yDACV,QAASC,EAAY,OACvB,CACF,CACF,CAAC","names":["import_create_create_app","import_node_path","package_default","templateRoot","path","answers","packageManager","package_default"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { useSyncStatus } from "./useSyncStatus";
|
|
3
3
|
import { TableRecord } from "@latticexyz/stash/internal";
|
|
4
|
-
import { SyncProgress } from "@latticexyz/store-sync/
|
|
4
|
+
import { SyncProgress } from "@latticexyz/store-sync/stash/common";
|
|
5
5
|
|
|
6
6
|
export type Props = {
|
|
7
7
|
children: ReactNode;
|
|
@@ -3,6 +3,7 @@ pragma solidity >=0.8.24;
|
|
|
3
3
|
|
|
4
4
|
import "forge-std/Test.sol";
|
|
5
5
|
import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
|
|
6
|
+
import { getKeysWithValue } from "@latticexyz/world-modules/src/modules/keyswithvalue/getKeysWithValue.sol";
|
|
6
7
|
|
|
7
8
|
import { IWorld } from "../src/codegen/world/IWorld.sol";
|
|
8
9
|
import { Position, PositionData } from "../src/codegen/tables/Position.sol";
|
|
@@ -19,6 +20,7 @@ contract MoveTest is MudTest {
|
|
|
19
20
|
|
|
20
21
|
IWorld(worldAddress).app__move(Direction.North);
|
|
21
22
|
position = Position.get(alice);
|
|
23
|
+
|
|
22
24
|
assertEq(position.x, 0);
|
|
23
25
|
assertEq(position.y, 1);
|
|
24
26
|
}
|
package/{templates/react-ecs → dist/templates/react}/packages/contracts/test/WorldTest.t.sol
RENAMED
|
@@ -3,6 +3,11 @@ pragma solidity >=0.8.24;
|
|
|
3
3
|
|
|
4
4
|
import "forge-std/Test.sol";
|
|
5
5
|
import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
|
|
6
|
+
import { getKeysWithValue } from "@latticexyz/world-modules/src/modules/keyswithvalue/getKeysWithValue.sol";
|
|
7
|
+
|
|
8
|
+
import { IWorld } from "../src/codegen/world/IWorld.sol";
|
|
9
|
+
import { Position, PositionData } from "../src/codegen/tables/Position.sol";
|
|
10
|
+
import { Direction } from "../src/codegen/common.sol";
|
|
6
11
|
|
|
7
12
|
contract WorldTest is MudTest {
|
|
8
13
|
function testWorldDeployed() public {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "mud-template-react",
|
|
2
|
+
"name": "mud-template-react-ecs",
|
|
3
3
|
"private": true,
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "pnpm recursive run build",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@latticexyz/explorer": "{{mud-version}}",
|
|
18
18
|
"@latticexyz/store-indexer": "{{mud-version}}",
|
|
19
19
|
"@types/debug": "4.1.7",
|
|
20
|
+
"@types/node": "^18",
|
|
20
21
|
"@typescript-eslint/eslint-plugin": "7.1.1",
|
|
21
22
|
"@typescript-eslint/parser": "7.1.1",
|
|
22
23
|
"eslint": "8.57.0",
|
|
@@ -6,39 +6,32 @@
|
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "vite build",
|
|
9
|
-
"dev": "vite",
|
|
9
|
+
"dev": "wait-port localhost:8545 && vite",
|
|
10
10
|
"preview": "vite preview",
|
|
11
11
|
"test": "tsc --noEmit"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@latticexyz/common": "{{mud-version}}",
|
|
15
|
-
"@latticexyz/
|
|
16
|
-
"@latticexyz/explorer": "{{mud-version}}",
|
|
15
|
+
"@latticexyz/dev-tools": "{{mud-version}}",
|
|
17
16
|
"@latticexyz/react": "{{mud-version}}",
|
|
18
17
|
"@latticexyz/recs": "{{mud-version}}",
|
|
19
18
|
"@latticexyz/schema-type": "{{mud-version}}",
|
|
20
19
|
"@latticexyz/store-sync": "{{mud-version}}",
|
|
21
20
|
"@latticexyz/utils": "{{mud-version}}",
|
|
22
21
|
"@latticexyz/world": "{{mud-version}}",
|
|
23
|
-
"@tanstack/react-query": "^5.63.0",
|
|
24
22
|
"contracts": "workspace:*",
|
|
25
|
-
"react": "18.2.0",
|
|
26
|
-
"react-dom": "18.2.0",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"viem": "2.21.19",
|
|
30
|
-
"wagmi": "2.12.11"
|
|
23
|
+
"react": "^18.2.0",
|
|
24
|
+
"react-dom": "^18.2.0",
|
|
25
|
+
"rxjs": "7.5.5",
|
|
26
|
+
"viem": "2.21.19"
|
|
31
27
|
},
|
|
32
28
|
"devDependencies": {
|
|
33
29
|
"@types/react": "18.2.22",
|
|
34
30
|
"@types/react-dom": "18.2.7",
|
|
35
|
-
"@vitejs/plugin-react": "^
|
|
36
|
-
"autoprefixer": "^10.4.20",
|
|
31
|
+
"@vitejs/plugin-react": "^3.1.0",
|
|
37
32
|
"eslint-plugin-react": "7.31.11",
|
|
38
33
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"vite": "^6.0.7",
|
|
42
|
-
"vite-plugin-mud": "{{mud-version}}"
|
|
34
|
+
"vite": "^4.2.1",
|
|
35
|
+
"wait-port": "^1.0.4"
|
|
43
36
|
}
|
|
44
37
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useComponentValue } from "@latticexyz/react";
|
|
2
|
+
import { useMUD } from "./MUDContext";
|
|
3
|
+
import { singletonEntity } from "@latticexyz/store-sync/recs";
|
|
4
|
+
|
|
5
|
+
export const App = () => {
|
|
6
|
+
const {
|
|
7
|
+
components: { Counter },
|
|
8
|
+
systemCalls: { increment },
|
|
9
|
+
} = useMUD();
|
|
10
|
+
|
|
11
|
+
const counter = useComponentValue(Counter, singletonEntity);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<div>
|
|
16
|
+
Counter: <span>{counter?.value ?? "??"}</span>
|
|
17
|
+
</div>
|
|
18
|
+
<button
|
|
19
|
+
type="button"
|
|
20
|
+
onClick={async (event) => {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
console.log("new counter value:", await increment());
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
Increment
|
|
26
|
+
</button>
|
|
27
|
+
</>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Create the system calls that the client can use to ask
|
|
3
|
+
* for changes in the World state (using the System contracts).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { getComponentValue } from "@latticexyz/recs";
|
|
7
|
+
import { ClientComponents } from "./createClientComponents";
|
|
8
|
+
import { SetupNetworkResult } from "./setupNetwork";
|
|
9
|
+
import { singletonEntity } from "@latticexyz/store-sync/recs";
|
|
10
|
+
|
|
11
|
+
export type SystemCalls = ReturnType<typeof createSystemCalls>;
|
|
12
|
+
|
|
13
|
+
export function createSystemCalls(
|
|
14
|
+
/*
|
|
15
|
+
* The parameter list informs TypeScript that:
|
|
16
|
+
*
|
|
17
|
+
* - The first parameter is expected to be a
|
|
18
|
+
* SetupNetworkResult, as defined in setupNetwork.ts
|
|
19
|
+
*
|
|
20
|
+
* Out of this parameter, we only care about two fields:
|
|
21
|
+
* - worldContract (which comes from getContract, see
|
|
22
|
+
* https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L63-L69).
|
|
23
|
+
*
|
|
24
|
+
* - waitForTransaction (which comes from syncToRecs, see
|
|
25
|
+
* https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L77-L83).
|
|
26
|
+
*
|
|
27
|
+
* - From the second parameter, which is a ClientComponent,
|
|
28
|
+
* we only care about Counter. This parameter comes to use
|
|
29
|
+
* through createClientComponents.ts, but it originates in
|
|
30
|
+
* syncToRecs
|
|
31
|
+
* (https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L77-L83).
|
|
32
|
+
*/
|
|
33
|
+
{ worldContract, waitForTransaction }: SetupNetworkResult,
|
|
34
|
+
{ Counter }: ClientComponents,
|
|
35
|
+
) {
|
|
36
|
+
const increment = async () => {
|
|
37
|
+
/*
|
|
38
|
+
* Because IncrementSystem
|
|
39
|
+
* (https://mud.dev/templates/typescript/contracts#incrementsystemsol)
|
|
40
|
+
* is in the root namespace, `.increment` can be called directly
|
|
41
|
+
* on the World contract.
|
|
42
|
+
*/
|
|
43
|
+
const tx = await worldContract.write.app__increment();
|
|
44
|
+
await waitForTransaction(tx);
|
|
45
|
+
return getComponentValue(Counter, singletonEntity);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
increment,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Network specific configuration for the client.
|
|
3
|
+
* By default connect to the anvil test network.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* By default the template just creates a temporary wallet
|
|
9
|
+
* (called a burner wallet).
|
|
10
|
+
*/
|
|
11
|
+
import { getBurnerPrivateKey } from "@latticexyz/common";
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Import the addresses of the World, possibly on multiple chains,
|
|
15
|
+
* from packages/contracts/worlds.json. When the contracts package
|
|
16
|
+
* deploys a new `World`, it updates this file.
|
|
17
|
+
*/
|
|
18
|
+
import worlds from "contracts/worlds.json";
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* The supported chains.
|
|
22
|
+
* By default, there are only two chains here:
|
|
23
|
+
*/
|
|
24
|
+
import { supportedChains } from "./supportedChains";
|
|
25
|
+
|
|
26
|
+
export async function getNetworkConfig() {
|
|
27
|
+
const params = new URLSearchParams(window.location.search);
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* The chain ID is the first item available from this list:
|
|
31
|
+
* 1. chainId query parameter
|
|
32
|
+
* 2. chainid query parameter
|
|
33
|
+
* 3. The VITE_CHAIN_ID environment variable set when the
|
|
34
|
+
* vite dev server was started or client was built
|
|
35
|
+
* 4. The default, 31337 (anvil)
|
|
36
|
+
*/
|
|
37
|
+
const chainId = Number(params.get("chainId") || params.get("chainid") || import.meta.env.VITE_CHAIN_ID || 31337);
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* Find the chain (unless it isn't in the list of supported chains).
|
|
41
|
+
*/
|
|
42
|
+
const chainIndex = supportedChains.findIndex((c) => c.id === chainId);
|
|
43
|
+
const chain = supportedChains[chainIndex];
|
|
44
|
+
if (!chain) {
|
|
45
|
+
throw new Error(`Chain ${chainId} not found`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
* Get the address of the World. If you want to use a
|
|
50
|
+
* different address than the one in worlds.json,
|
|
51
|
+
* provide it as worldAddress in the query string.
|
|
52
|
+
*/
|
|
53
|
+
const world = worlds[chain.id.toString()];
|
|
54
|
+
const worldAddress = params.get("worldAddress") || world?.address;
|
|
55
|
+
if (!worldAddress) {
|
|
56
|
+
throw new Error(`No world address found for chain ${chainId}. Did you run \`mud deploy\`?`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* MUD clients use events to synchronize the database, meaning
|
|
61
|
+
* they need to look as far back as when the World was started.
|
|
62
|
+
* The block number for the World start can be specified either
|
|
63
|
+
* on the URL (as initialBlockNumber) or in the worlds.json
|
|
64
|
+
* file. If neither has it, it starts at the first block, zero.
|
|
65
|
+
*/
|
|
66
|
+
const initialBlockNumber = params.has("initialBlockNumber")
|
|
67
|
+
? Number(params.get("initialBlockNumber"))
|
|
68
|
+
: world?.blockNumber ?? 0n;
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
privateKey: getBurnerPrivateKey(),
|
|
72
|
+
chainId,
|
|
73
|
+
chain,
|
|
74
|
+
worldAddress,
|
|
75
|
+
initialBlockNumber,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>a MUD
|
|
6
|
+
<title>a minimal MUD client</title>
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<div id="react-root"></div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, ReactNode, useContext } from "react";
|
|
2
|
+
import { SetupResult } from "./mud/setup";
|
|
3
|
+
|
|
4
|
+
const MUDContext = createContext<SetupResult | null>(null);
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
value: SetupResult;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const MUDProvider = ({ children, value }: Props) => {
|
|
12
|
+
const currentValue = useContext(MUDContext);
|
|
13
|
+
if (currentValue) throw new Error("MUDProvider can only be used once");
|
|
14
|
+
return <MUDContext.Provider value={value}>{children}</MUDContext.Provider>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const useMUD = () => {
|
|
18
|
+
const value = useContext(MUDContext);
|
|
19
|
+
if (!value) throw new Error("Must be used within a MUDProvider");
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import ReactDOM from "react-dom/client";
|
|
2
|
+
import { App } from "./App";
|
|
3
|
+
import { setup } from "./mud/setup";
|
|
4
|
+
import { MUDProvider } from "./MUDContext";
|
|
5
|
+
import mudConfig from "contracts/mud.config";
|
|
6
|
+
|
|
7
|
+
const rootElement = document.getElementById("react-root");
|
|
8
|
+
if (!rootElement) throw new Error("React root not found");
|
|
9
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
10
|
+
|
|
11
|
+
// TODO: figure out if we actually want this to be async or if we should render something else in the meantime
|
|
12
|
+
setup().then(async (result) => {
|
|
13
|
+
root.render(
|
|
14
|
+
<MUDProvider value={result}>
|
|
15
|
+
<App />
|
|
16
|
+
</MUDProvider>,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// https://vitejs.dev/guide/env-and-mode.html
|
|
20
|
+
if (import.meta.env.DEV) {
|
|
21
|
+
const { mount: mountDevTools } = await import("@latticexyz/dev-tools");
|
|
22
|
+
mountDevTools({
|
|
23
|
+
config: mudConfig,
|
|
24
|
+
publicClient: result.network.publicClient,
|
|
25
|
+
walletClient: result.network.walletClient,
|
|
26
|
+
latestBlock$: result.network.latestBlock$,
|
|
27
|
+
storedBlockLogs$: result.network.storedBlockLogs$,
|
|
28
|
+
worldAddress: result.network.worldContract.address,
|
|
29
|
+
worldAbi: result.network.worldContract.abi,
|
|
30
|
+
write$: result.network.write$,
|
|
31
|
+
recsWorld: result.network.world,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { defineConfig } from "vite";
|
|
2
2
|
import react from "@vitejs/plugin-react";
|
|
3
|
-
import { mud } from "vite-plugin-mud";
|
|
4
3
|
|
|
5
4
|
export default defineConfig({
|
|
6
|
-
plugins: [react()
|
|
5
|
+
plugins: [react()],
|
|
6
|
+
server: {
|
|
7
|
+
port: 3000,
|
|
8
|
+
fs: {
|
|
9
|
+
strict: false,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
7
12
|
build: {
|
|
8
13
|
target: "es2022",
|
|
9
14
|
minify: true,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
procs:
|
|
2
|
+
client:
|
|
3
|
+
cwd: packages/client
|
|
4
|
+
shell: pnpm run dev
|
|
5
|
+
contracts:
|
|
6
|
+
cwd: packages/contracts
|
|
7
|
+
shell: pnpm mud dev-contracts --rpc http://127.0.0.1:8545
|
|
8
|
+
anvil:
|
|
9
|
+
cwd: packages/contracts
|
|
10
|
+
shell: anvil --base-fee 0 --block-time 2
|
|
11
|
+
explorer:
|
|
12
|
+
cwd: packages/contracts
|
|
13
|
+
shell: pnpm explorer
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Creates components for use by the client.
|
|
3
|
+
*
|
|
4
|
+
* By default it returns the components from setupNetwork.ts, those which are
|
|
5
|
+
* automatically inferred from the mud.config.ts table definitions.
|
|
6
|
+
*
|
|
7
|
+
* However, you can add or override components here as needed. This
|
|
8
|
+
* lets you add user defined components, which may or may not have
|
|
9
|
+
* an onchain component.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { SetupNetworkResult } from "./setupNetwork";
|
|
13
|
+
|
|
14
|
+
export type ClientComponents = ReturnType<typeof createClientComponents>;
|
|
15
|
+
|
|
16
|
+
export function createClientComponents({ components }: SetupNetworkResult) {
|
|
17
|
+
return {
|
|
18
|
+
...components,
|
|
19
|
+
// add your client components or overrides here
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file sets up all the definitions required for a MUD client.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createClientComponents } from "./createClientComponents";
|
|
6
|
+
import { createSystemCalls } from "./createSystemCalls";
|
|
7
|
+
import { setupNetwork } from "./setupNetwork";
|
|
8
|
+
|
|
9
|
+
export type SetupResult = Awaited<ReturnType<typeof setup>>;
|
|
10
|
+
|
|
11
|
+
export async function setup() {
|
|
12
|
+
const network = await setupNetwork();
|
|
13
|
+
const components = createClientComponents(network);
|
|
14
|
+
const systemCalls = createSystemCalls(network, components);
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
network,
|
|
18
|
+
components,
|
|
19
|
+
systemCalls,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MUD client code is built on top of viem
|
|
3
|
+
* (https://viem.sh/docs/getting-started.html).
|
|
4
|
+
* This line imports the functions we need from it.
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
createPublicClient,
|
|
8
|
+
fallback,
|
|
9
|
+
webSocket,
|
|
10
|
+
http,
|
|
11
|
+
createWalletClient,
|
|
12
|
+
Hex,
|
|
13
|
+
ClientConfig,
|
|
14
|
+
getContract,
|
|
15
|
+
} from "viem";
|
|
16
|
+
import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
|
|
17
|
+
|
|
18
|
+
import { getNetworkConfig } from "./getNetworkConfig";
|
|
19
|
+
import { world } from "./world";
|
|
20
|
+
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
|
|
21
|
+
import { createBurnerAccount, transportObserver, ContractWrite } from "@latticexyz/common";
|
|
22
|
+
import { transactionQueue, writeObserver } from "@latticexyz/common/actions";
|
|
23
|
+
|
|
24
|
+
import { Subject, share } from "rxjs";
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* Import our MUD config, which includes strong types for
|
|
28
|
+
* our tables and other config options. We use this to generate
|
|
29
|
+
* things like RECS components and get back strong types for them.
|
|
30
|
+
*
|
|
31
|
+
* See https://mud.dev/templates/typescript/contracts#mudconfigts
|
|
32
|
+
* for the source of this information.
|
|
33
|
+
*/
|
|
34
|
+
import mudConfig from "contracts/mud.config";
|
|
35
|
+
|
|
36
|
+
export type SetupNetworkResult = Awaited<ReturnType<typeof setupNetwork>>;
|
|
37
|
+
|
|
38
|
+
export async function setupNetwork() {
|
|
39
|
+
const networkConfig = await getNetworkConfig();
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Create a viem public (read only) client
|
|
43
|
+
* (https://viem.sh/docs/clients/public.html)
|
|
44
|
+
*/
|
|
45
|
+
const clientOptions = {
|
|
46
|
+
chain: networkConfig.chain,
|
|
47
|
+
transport: transportObserver(fallback([webSocket(), http()])),
|
|
48
|
+
pollingInterval: 1000,
|
|
49
|
+
} as const satisfies ClientConfig;
|
|
50
|
+
|
|
51
|
+
const publicClient = createPublicClient(clientOptions);
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* Create an observable for contract writes that we can
|
|
55
|
+
* pass into MUD dev tools for transaction observability.
|
|
56
|
+
*/
|
|
57
|
+
const write$ = new Subject<ContractWrite>();
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* Create a temporary wallet and a viem client for it
|
|
61
|
+
* (see https://viem.sh/docs/clients/wallet.html).
|
|
62
|
+
*/
|
|
63
|
+
const burnerAccount = createBurnerAccount(networkConfig.privateKey as Hex);
|
|
64
|
+
const burnerWalletClient = createWalletClient({
|
|
65
|
+
...clientOptions,
|
|
66
|
+
account: burnerAccount,
|
|
67
|
+
})
|
|
68
|
+
.extend(transactionQueue())
|
|
69
|
+
.extend(writeObserver({ onWrite: (write) => write$.next(write) }));
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
* Create an object for communicating with the deployed World.
|
|
73
|
+
*/
|
|
74
|
+
const worldContract = getContract({
|
|
75
|
+
address: networkConfig.worldAddress as Hex,
|
|
76
|
+
abi: IWorldAbi,
|
|
77
|
+
client: { public: publicClient, wallet: burnerWalletClient },
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* Sync on-chain state into RECS and keeps our client in sync.
|
|
82
|
+
* Uses the MUD indexer if available, otherwise falls back
|
|
83
|
+
* to the viem publicClient to make RPC calls to fetch MUD
|
|
84
|
+
* events from the chain.
|
|
85
|
+
*/
|
|
86
|
+
const { components, latestBlock$, storedBlockLogs$, waitForTransaction } = await syncToRecs({
|
|
87
|
+
world,
|
|
88
|
+
config: mudConfig,
|
|
89
|
+
address: networkConfig.worldAddress as Hex,
|
|
90
|
+
publicClient,
|
|
91
|
+
startBlock: BigInt(networkConfig.initialBlockNumber),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
world,
|
|
96
|
+
components,
|
|
97
|
+
playerEntity: encodeEntity({ address: "address" }, { address: burnerWalletClient.account.address }),
|
|
98
|
+
publicClient,
|
|
99
|
+
walletClient: burnerWalletClient,
|
|
100
|
+
latestBlock$,
|
|
101
|
+
storedBlockLogs$,
|
|
102
|
+
waitForTransaction,
|
|
103
|
+
worldContract,
|
|
104
|
+
write$: write$.asObservable().pipe(share()),
|
|
105
|
+
};
|
|
106
|
+
}
|