create-mud 2.2.17-d5f4e1e44bbc260ff21dacdfab0e0f8389e9f304 → 2.2.17-f1d5432fe2c9abb19fa378f790217e67d6dd8504

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/package.json +1 -1
  4. package/templates/react/packages/client/src/mud/Synced.tsx +1 -1
  5. package/templates/react/packages/contracts/.env +1 -1
  6. package/templates/react/packages/contracts/test/MoveTest.t.sol +0 -2
  7. package/templates/react/packages/contracts/test/WorldTest.t.sol +0 -5
  8. package/templates/react-ecs/mprocs.yaml +9 -1
  9. package/templates/react-ecs/package.json +1 -2
  10. package/templates/react-ecs/packages/client/index.html +2 -2
  11. package/templates/react-ecs/packages/client/package.json +16 -9
  12. package/templates/react-ecs/packages/client/postcss.config.cjs +6 -0
  13. package/templates/react-ecs/packages/client/src/App.tsx +66 -21
  14. package/templates/react-ecs/packages/client/src/Providers.tsx +29 -0
  15. package/templates/react-ecs/packages/client/src/common.ts +27 -0
  16. package/templates/react-ecs/packages/client/src/game/GameMap.tsx +112 -0
  17. package/templates/react-ecs/packages/client/src/game/useKeyboardMovement.ts +26 -0
  18. package/templates/react-ecs/packages/client/src/index.tsx +17 -32
  19. package/templates/react-ecs/packages/client/src/mud/Explorer.tsx +32 -0
  20. package/templates/react-ecs/packages/client/src/mud/Synced.tsx +14 -0
  21. package/templates/react-ecs/packages/client/src/mud/recs.ts +6 -0
  22. package/templates/react-ecs/packages/client/src/mud/useSyncStatus.ts +17 -0
  23. package/templates/react-ecs/packages/client/src/mud/useWorldContract.ts +44 -0
  24. package/templates/react-ecs/packages/client/src/ui/AsyncButton.tsx +41 -0
  25. package/templates/react-ecs/packages/client/src/ui/ErrorFallback.tsx +58 -0
  26. package/templates/react-ecs/packages/client/src/ui/icons/ArrowDownIcon.tsx +22 -0
  27. package/templates/react-ecs/packages/client/src/ui/icons/MUDIcon.tsx +25 -0
  28. package/templates/react-ecs/packages/client/src/wagmiConfig.ts +49 -0
  29. package/templates/react-ecs/packages/client/tailwind.config.ts +10 -0
  30. package/templates/react-ecs/packages/client/tsconfig.json +1 -1
  31. package/templates/react-ecs/packages/client/vite.config.ts +2 -7
  32. package/templates/react-ecs/packages/contracts/.env +1 -1
  33. package/templates/react-ecs/packages/contracts/mud.config.ts +18 -6
  34. package/templates/react-ecs/packages/contracts/out/IWorld.sol/IWorld.abi.json +2039 -0
  35. package/templates/react-ecs/packages/contracts/package.json +1 -0
  36. package/templates/react-ecs/packages/contracts/script/PostDeploy.s.sol +1 -5
  37. package/templates/react-ecs/packages/contracts/src/Entity.sol +20 -0
  38. package/templates/react-ecs/packages/contracts/src/MoveSystem.sol +30 -0
  39. package/templates/react-ecs/packages/contracts/src/SpawnSystem.sol +18 -0
  40. package/templates/react-ecs/packages/contracts/src/codegen/common.sol +11 -0
  41. package/templates/react-ecs/packages/contracts/src/codegen/index.sol +3 -1
  42. package/templates/react-ecs/packages/contracts/src/codegen/tables/{Counter.sol → EntityCount.sol} +35 -35
  43. package/templates/react-ecs/packages/contracts/src/codegen/tables/Owner.sol +202 -0
  44. package/templates/react-ecs/packages/contracts/src/codegen/tables/Position.sol +321 -0
  45. package/templates/react-ecs/packages/contracts/src/codegen/world/IMoveSystem.sol +16 -0
  46. package/templates/react-ecs/packages/contracts/src/codegen/world/{IIncrementSystem.sol → ISpawnSystem.sol} +5 -3
  47. package/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol +3 -2
  48. package/templates/react-ecs/packages/contracts/src/createEntity.sol +11 -0
  49. package/templates/react-ecs/packages/contracts/test/MoveTest.t.sol +39 -0
  50. package/templates/react-ecs/packages/contracts/test/WorldTest.t.sol +16 -0
  51. package/templates/react-ecs/packages/contracts/worlds.json +1 -1
  52. package/templates/react-ecs/packages/client/src/MUDContext.tsx +0 -21
  53. package/templates/react-ecs/packages/client/src/mud/createClientComponents.ts +0 -21
  54. package/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts +0 -51
  55. package/templates/react-ecs/packages/client/src/mud/getNetworkConfig.ts +0 -77
  56. package/templates/react-ecs/packages/client/src/mud/setup.ts +0 -21
  57. package/templates/react-ecs/packages/client/src/mud/setupNetwork.ts +0 -106
  58. package/templates/react-ecs/packages/client/src/mud/supportedChains.ts +0 -20
  59. package/templates/react-ecs/packages/client/src/mud/world.ts +0 -3
  60. package/templates/react-ecs/packages/contracts/src/systems/IncrementSystem.sol +0 -14
  61. package/templates/react-ecs/packages/contracts/test/CounterTest.t.sol +0 -31
@@ -1,106 +0,0 @@
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
- }
@@ -1,20 +0,0 @@
1
- /*
2
- * The supported chains.
3
- * By default, there are only two chains here:
4
- *
5
- * - mudFoundry, the chain running on anvil that pnpm dev
6
- * starts by default. It is similar to the viem anvil chain
7
- * (see https://viem.sh/docs/clients/test.html), but with the
8
- * basefee set to zero to avoid transaction fees.
9
- * - Redstone, our production blockchain (https://redstone.xyz/)
10
- * - Garnet, our test blockchain (https://garnetchain.com/))
11
- *
12
- */
13
-
14
- import { MUDChain, mudFoundry, redstone, garnet } from "@latticexyz/common/chains";
15
-
16
- /*
17
- * See https://mud.dev/guides/hello-world/add-chain-client
18
- * for instructions on how to add networks.
19
- */
20
- export const supportedChains: MUDChain[] = [mudFoundry, redstone, garnet];
@@ -1,3 +0,0 @@
1
- import { createWorld } from "@latticexyz/recs";
2
-
3
- export const world = createWorld();
@@ -1,14 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity >=0.8.24;
3
-
4
- import { System } from "@latticexyz/world/src/System.sol";
5
- import { Counter } from "../codegen/index.sol";
6
-
7
- contract IncrementSystem is System {
8
- function increment() public returns (uint32) {
9
- uint32 counter = Counter.get();
10
- uint32 newValue = counter + 1;
11
- Counter.set(newValue);
12
- return newValue;
13
- }
14
- }
@@ -1,31 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity >=0.8.24;
3
-
4
- import "forge-std/Test.sol";
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 { Counter } from "../src/codegen/index.sol";
10
-
11
- contract CounterTest is MudTest {
12
- function testWorldExists() public {
13
- uint256 codeSize;
14
- address addr = worldAddress;
15
- assembly {
16
- codeSize := extcodesize(addr)
17
- }
18
- assertTrue(codeSize > 0);
19
- }
20
-
21
- function testCounter() public {
22
- // Expect the counter to be 1 because it was incremented in the PostDeploy script.
23
- uint32 counter = Counter.get();
24
- assertEq(counter, 1);
25
-
26
- // Expect the counter to be 2 after calling increment.
27
- IWorld(worldAddress).app__increment();
28
- counter = Counter.get();
29
- assertEq(counter, 2);
30
- }
31
- }