create-mud 2.2.17-d252fd65ce1e5a2085d1a43ba02df7e985d90aa5 → 2.2.17-d5210ce502a781b858a575a715d97dfd3a91c29d

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 (122) hide show
  1. package/dist/cli.js +8 -2
  2. package/dist/cli.js.map +1 -1
  3. package/package.json +6 -6
  4. package/templates/phaser/.gitignore_ +7 -0
  5. package/templates/phaser/packages/art/.gitignore_ +0 -0
  6. package/templates/phaser/packages/client/.gitignore_ +3 -0
  7. package/templates/phaser/packages/contracts/.gitignore_ +9 -0
  8. package/templates/phaser/packages/contracts/worlds.json +2 -2
  9. package/templates/react/.gitignore_ +16 -0
  10. package/templates/react/mprocs.yaml +9 -1
  11. package/templates/react/packages/client/.gitignore_ +1 -0
  12. package/templates/react/packages/client/index.html +2 -2
  13. package/templates/react/packages/client/package.json +17 -9
  14. package/templates/react/packages/client/postcss.config.cjs +6 -0
  15. package/templates/react/packages/client/src/App.tsx +41 -100
  16. package/templates/react/packages/client/src/Providers.tsx +35 -0
  17. package/templates/react/packages/client/src/common.ts +26 -0
  18. package/templates/react/packages/client/src/game/GameMap.tsx +102 -0
  19. package/templates/react/packages/client/src/game/useKeyboardMovement.ts +26 -0
  20. package/templates/react/packages/client/src/index.tsx +17 -32
  21. package/templates/react/packages/client/src/mud/Explorer.tsx +32 -0
  22. package/templates/react/packages/client/src/mud/Synced.tsx +14 -0
  23. package/templates/react/packages/client/src/mud/stash.ts +4 -0
  24. package/templates/react/packages/client/src/mud/useSyncStatus.ts +21 -0
  25. package/templates/react/packages/client/src/mud/useWorldContract.ts +44 -0
  26. package/templates/react/packages/client/src/ui/AsyncButton.tsx +41 -0
  27. package/templates/react/packages/client/src/ui/ErrorFallback.tsx +58 -0
  28. package/templates/react/packages/client/src/ui/icons/ArrowDownIcon.tsx +22 -0
  29. package/templates/react/packages/client/src/ui/icons/MUDIcon.tsx +25 -0
  30. package/templates/react/packages/client/src/wagmiConfig.ts +49 -0
  31. package/templates/react/packages/client/tailwind.config.ts +10 -0
  32. package/templates/react/packages/client/tsconfig.json +1 -1
  33. package/templates/react/packages/client/vite.config.ts +2 -7
  34. package/templates/react/packages/contracts/.env +1 -1
  35. package/templates/react/packages/contracts/.gitignore_ +13 -0
  36. package/templates/react/packages/contracts/mud.config.ts +6 -8
  37. package/templates/react/packages/contracts/out/IWorld.sol/IWorld.abi.json +2021 -0
  38. package/templates/react/packages/contracts/package.json +1 -0
  39. package/templates/react/packages/contracts/script/PostDeploy.s.sol +1 -9
  40. package/templates/react/packages/contracts/src/MoveSystem.sol +26 -0
  41. package/templates/react/packages/contracts/src/codegen/common.sol +11 -0
  42. package/templates/react/packages/contracts/src/codegen/index.sol +1 -1
  43. package/templates/react/packages/contracts/src/codegen/tables/Position.sol +318 -0
  44. package/templates/{react-ecs/packages/contracts/src/codegen/world/IIncrementSystem.sol → react/packages/contracts/src/codegen/world/IMoveSystem.sol} +5 -3
  45. package/templates/react/packages/contracts/src/codegen/world/IWorld.sol +2 -2
  46. package/templates/react/packages/contracts/test/MoveTest.t.sol +25 -0
  47. package/templates/react/packages/contracts/test/WorldTest.t.sol +16 -0
  48. package/templates/react/packages/contracts/worlds.json +2 -2
  49. package/templates/react-ecs/.gitignore_ +16 -0
  50. package/templates/react-ecs/mprocs.yaml +9 -1
  51. package/templates/react-ecs/package.json +1 -2
  52. package/templates/react-ecs/packages/client/.gitignore_ +1 -0
  53. package/templates/react-ecs/packages/client/index.html +2 -2
  54. package/templates/react-ecs/packages/client/package.json +16 -9
  55. package/templates/react-ecs/packages/client/postcss.config.cjs +6 -0
  56. package/templates/react-ecs/packages/client/src/App.tsx +66 -21
  57. package/templates/react-ecs/packages/client/src/Providers.tsx +29 -0
  58. package/templates/react-ecs/packages/client/src/common.ts +27 -0
  59. package/templates/react-ecs/packages/client/src/game/GameMap.tsx +112 -0
  60. package/templates/react-ecs/packages/client/src/game/useKeyboardMovement.ts +26 -0
  61. package/templates/react-ecs/packages/client/src/index.tsx +17 -32
  62. package/templates/react-ecs/packages/client/src/mud/Explorer.tsx +32 -0
  63. package/templates/react-ecs/packages/client/src/mud/Synced.tsx +14 -0
  64. package/templates/react-ecs/packages/client/src/mud/recs.ts +6 -0
  65. package/templates/react-ecs/packages/client/src/mud/useSyncStatus.ts +17 -0
  66. package/templates/react-ecs/packages/client/src/mud/useWorldContract.ts +44 -0
  67. package/templates/react-ecs/packages/client/src/ui/AsyncButton.tsx +41 -0
  68. package/templates/react-ecs/packages/client/src/ui/ErrorFallback.tsx +58 -0
  69. package/templates/react-ecs/packages/client/src/ui/icons/ArrowDownIcon.tsx +22 -0
  70. package/templates/react-ecs/packages/client/src/ui/icons/MUDIcon.tsx +25 -0
  71. package/templates/react-ecs/packages/client/src/wagmiConfig.ts +49 -0
  72. package/templates/react-ecs/packages/client/tailwind.config.ts +10 -0
  73. package/templates/react-ecs/packages/client/tsconfig.json +1 -1
  74. package/templates/react-ecs/packages/client/vite.config.ts +2 -7
  75. package/templates/react-ecs/packages/contracts/.env +1 -1
  76. package/templates/react-ecs/packages/contracts/.gitignore_ +13 -0
  77. package/templates/react-ecs/packages/contracts/mud.config.ts +11 -6
  78. package/templates/react-ecs/packages/contracts/out/IWorld.sol/IWorld.abi.json +2039 -0
  79. package/templates/react-ecs/packages/contracts/package.json +1 -0
  80. package/templates/react-ecs/packages/contracts/script/PostDeploy.s.sol +1 -5
  81. package/templates/react-ecs/packages/contracts/src/Entity.sol +20 -0
  82. package/templates/react-ecs/packages/contracts/src/MoveSystem.sol +30 -0
  83. package/templates/react-ecs/packages/contracts/src/SpawnSystem.sol +18 -0
  84. package/templates/react-ecs/packages/contracts/src/codegen/common.sol +11 -0
  85. package/templates/react-ecs/packages/contracts/src/codegen/index.sol +3 -1
  86. package/templates/react-ecs/packages/contracts/src/codegen/tables/{Counter.sol → EntityCount.sol} +35 -35
  87. package/templates/react-ecs/packages/contracts/src/codegen/tables/Owner.sol +202 -0
  88. package/templates/react-ecs/packages/contracts/src/codegen/tables/Position.sol +321 -0
  89. package/templates/{react/packages/contracts/src/codegen/world/ITasksSystem.sol → react-ecs/packages/contracts/src/codegen/world/IMoveSystem.sol} +6 -9
  90. package/templates/react-ecs/packages/contracts/src/codegen/world/ISpawnSystem.sol +15 -0
  91. package/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol +3 -2
  92. package/templates/react-ecs/packages/contracts/src/createEntity.sol +11 -0
  93. package/templates/react-ecs/packages/contracts/test/MoveTest.t.sol +39 -0
  94. package/templates/react-ecs/packages/contracts/test/WorldTest.t.sol +16 -0
  95. package/templates/react-ecs/packages/contracts/worlds.json +2 -2
  96. package/templates/threejs/.gitignore_ +7 -0
  97. package/templates/threejs/packages/client/.gitignore_ +3 -0
  98. package/templates/threejs/packages/contracts/.gitignore_ +9 -0
  99. package/templates/threejs/packages/contracts/worlds.json +2 -2
  100. package/templates/vanilla/.gitignore_ +7 -0
  101. package/templates/vanilla/packages/client/.gitignore_ +3 -0
  102. package/templates/vanilla/packages/contracts/.gitignore_ +9 -0
  103. package/templates/vanilla/packages/contracts/worlds.json +2 -2
  104. package/templates/react/packages/client/src/MUDContext.tsx +0 -21
  105. package/templates/react/packages/client/src/mud/createSystemCalls.ts +0 -56
  106. package/templates/react/packages/client/src/mud/getNetworkConfig.ts +0 -76
  107. package/templates/react/packages/client/src/mud/setup.ts +0 -18
  108. package/templates/react/packages/client/src/mud/setupNetwork.ts +0 -101
  109. package/templates/react/packages/client/src/mud/supportedChains.ts +0 -20
  110. package/templates/react/packages/contracts/src/codegen/tables/Tasks.sol +0 -522
  111. package/templates/react/packages/contracts/src/systems/TasksSystem.sol +0 -24
  112. package/templates/react/packages/contracts/test/TasksTest.t.sol +0 -30
  113. package/templates/react-ecs/packages/client/src/MUDContext.tsx +0 -21
  114. package/templates/react-ecs/packages/client/src/mud/createClientComponents.ts +0 -21
  115. package/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts +0 -51
  116. package/templates/react-ecs/packages/client/src/mud/getNetworkConfig.ts +0 -77
  117. package/templates/react-ecs/packages/client/src/mud/setup.ts +0 -21
  118. package/templates/react-ecs/packages/client/src/mud/setupNetwork.ts +0 -106
  119. package/templates/react-ecs/packages/client/src/mud/supportedChains.ts +0 -20
  120. package/templates/react-ecs/packages/client/src/mud/world.ts +0 -3
  121. package/templates/react-ecs/packages/contracts/src/systems/IncrementSystem.sol +0 -14
  122. package/templates/react-ecs/packages/contracts/test/CounterTest.t.sol +0 -31
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@latticexyz/cli": "{{mud-version}}",
20
+ "@latticexyz/entrykit": "{{mud-version}}",
20
21
  "@latticexyz/schema-type": "{{mud-version}}",
21
22
  "@latticexyz/store": "{{mud-version}}",
22
23
  "@latticexyz/world": "{{mud-version}}",
@@ -6,7 +6,6 @@ import { console } from "forge-std/console.sol";
6
6
  import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
7
7
 
8
8
  import { IWorld } from "../src/codegen/world/IWorld.sol";
9
- import { Tasks, TasksData } from "../src/codegen/index.sol";
10
9
 
11
10
  contract PostDeploy is Script {
12
11
  function run(address worldAddress) external {
@@ -19,14 +18,7 @@ contract PostDeploy is Script {
19
18
  // Start broadcasting transactions from the deployer account
20
19
  vm.startBroadcast(deployerPrivateKey);
21
20
 
22
- // We can set table records directly
23
- Tasks.set("1", TasksData({ description: "Walk the dog", createdAt: block.timestamp, completedAt: 0 }));
24
-
25
- // Or we can call our own systems
26
- IWorld(worldAddress).app__addTask("Take out the trash");
27
-
28
- bytes32 key = IWorld(worldAddress).app__addTask("Do the dishes");
29
- IWorld(worldAddress).app__completeTask(key);
21
+ // TODO
30
22
 
31
23
  vm.stopBroadcast();
32
24
  }
@@ -0,0 +1,26 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.24;
3
+
4
+ import { System } from "@latticexyz/world/src/System.sol";
5
+
6
+ import { Direction } from "./codegen/common.sol";
7
+ import { Position, PositionData } from "./codegen/tables/Position.sol";
8
+
9
+ contract MoveSystem is System {
10
+ function move(Direction direction) public {
11
+ address player = _msgSender();
12
+ PositionData memory position = Position.get(player);
13
+
14
+ if (direction == Direction.North) {
15
+ position.y += 1;
16
+ } else if (direction == Direction.East) {
17
+ position.x += 1;
18
+ } else if (direction == Direction.South) {
19
+ position.y -= 1;
20
+ } else if (direction == Direction.West) {
21
+ position.x -= 1;
22
+ }
23
+
24
+ Position.set(player, position);
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.24;
3
+
4
+ /* Autogenerated file. Do not edit manually. */
5
+
6
+ enum Direction {
7
+ North,
8
+ East,
9
+ South,
10
+ West
11
+ }
@@ -3,4 +3,4 @@ pragma solidity >=0.8.24;
3
3
 
4
4
  /* Autogenerated file. Do not edit manually. */
5
5
 
6
- import { Tasks, TasksData } from "./tables/Tasks.sol";
6
+ import { Position, PositionData } from "./tables/Position.sol";
@@ -0,0 +1,318 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.24;
3
+
4
+ /* Autogenerated file. Do not edit manually. */
5
+
6
+ // Import store internals
7
+ import { IStore } from "@latticexyz/store/src/IStore.sol";
8
+ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
9
+ import { StoreCore } from "@latticexyz/store/src/StoreCore.sol";
10
+ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
11
+ import { Memory } from "@latticexyz/store/src/Memory.sol";
12
+ import { SliceLib } from "@latticexyz/store/src/Slice.sol";
13
+ import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
14
+ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
15
+ import { Schema } from "@latticexyz/store/src/Schema.sol";
16
+ import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol";
17
+ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
18
+
19
+ struct PositionData {
20
+ int32 x;
21
+ int32 y;
22
+ }
23
+
24
+ library Position {
25
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "app", name: "Position", typeId: RESOURCE_TABLE });`
26
+ ResourceId constant _tableId = ResourceId.wrap(0x74626170700000000000000000000000506f736974696f6e0000000000000000);
27
+
28
+ FieldLayout constant _fieldLayout =
29
+ FieldLayout.wrap(0x0008020004040000000000000000000000000000000000000000000000000000);
30
+
31
+ // Hex-encoded key schema of (address)
32
+ Schema constant _keySchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000);
33
+ // Hex-encoded value schema of (int32, int32)
34
+ Schema constant _valueSchema = Schema.wrap(0x0008020023230000000000000000000000000000000000000000000000000000);
35
+
36
+ /**
37
+ * @notice Get the table's key field names.
38
+ * @return keyNames An array of strings with the names of key fields.
39
+ */
40
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
41
+ keyNames = new string[](1);
42
+ keyNames[0] = "player";
43
+ }
44
+
45
+ /**
46
+ * @notice Get the table's value field names.
47
+ * @return fieldNames An array of strings with the names of value fields.
48
+ */
49
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
50
+ fieldNames = new string[](2);
51
+ fieldNames[0] = "x";
52
+ fieldNames[1] = "y";
53
+ }
54
+
55
+ /**
56
+ * @notice Register the table with its config.
57
+ */
58
+ function register() internal {
59
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
60
+ }
61
+
62
+ /**
63
+ * @notice Register the table with its config.
64
+ */
65
+ function _register() internal {
66
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
67
+ }
68
+
69
+ /**
70
+ * @notice Get x.
71
+ */
72
+ function getX(address player) internal view returns (int32 x) {
73
+ bytes32[] memory _keyTuple = new bytes32[](1);
74
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
75
+
76
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
77
+ return (int32(uint32(bytes4(_blob))));
78
+ }
79
+
80
+ /**
81
+ * @notice Get x.
82
+ */
83
+ function _getX(address player) internal view returns (int32 x) {
84
+ bytes32[] memory _keyTuple = new bytes32[](1);
85
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
86
+
87
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
88
+ return (int32(uint32(bytes4(_blob))));
89
+ }
90
+
91
+ /**
92
+ * @notice Set x.
93
+ */
94
+ function setX(address player, int32 x) internal {
95
+ bytes32[] memory _keyTuple = new bytes32[](1);
96
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
97
+
98
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout);
99
+ }
100
+
101
+ /**
102
+ * @notice Set x.
103
+ */
104
+ function _setX(address player, int32 x) internal {
105
+ bytes32[] memory _keyTuple = new bytes32[](1);
106
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
107
+
108
+ StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout);
109
+ }
110
+
111
+ /**
112
+ * @notice Get y.
113
+ */
114
+ function getY(address player) internal view returns (int32 y) {
115
+ bytes32[] memory _keyTuple = new bytes32[](1);
116
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
117
+
118
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
119
+ return (int32(uint32(bytes4(_blob))));
120
+ }
121
+
122
+ /**
123
+ * @notice Get y.
124
+ */
125
+ function _getY(address player) internal view returns (int32 y) {
126
+ bytes32[] memory _keyTuple = new bytes32[](1);
127
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
128
+
129
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
130
+ return (int32(uint32(bytes4(_blob))));
131
+ }
132
+
133
+ /**
134
+ * @notice Set y.
135
+ */
136
+ function setY(address player, int32 y) internal {
137
+ bytes32[] memory _keyTuple = new bytes32[](1);
138
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
139
+
140
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout);
141
+ }
142
+
143
+ /**
144
+ * @notice Set y.
145
+ */
146
+ function _setY(address player, int32 y) internal {
147
+ bytes32[] memory _keyTuple = new bytes32[](1);
148
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
149
+
150
+ StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout);
151
+ }
152
+
153
+ /**
154
+ * @notice Get the full data.
155
+ */
156
+ function get(address player) internal view returns (PositionData memory _table) {
157
+ bytes32[] memory _keyTuple = new bytes32[](1);
158
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
159
+
160
+ (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord(
161
+ _tableId,
162
+ _keyTuple,
163
+ _fieldLayout
164
+ );
165
+ return decode(_staticData, _encodedLengths, _dynamicData);
166
+ }
167
+
168
+ /**
169
+ * @notice Get the full data.
170
+ */
171
+ function _get(address player) internal view returns (PositionData memory _table) {
172
+ bytes32[] memory _keyTuple = new bytes32[](1);
173
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
174
+
175
+ (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord(
176
+ _tableId,
177
+ _keyTuple,
178
+ _fieldLayout
179
+ );
180
+ return decode(_staticData, _encodedLengths, _dynamicData);
181
+ }
182
+
183
+ /**
184
+ * @notice Set the full data using individual values.
185
+ */
186
+ function set(address player, int32 x, int32 y) internal {
187
+ bytes memory _staticData = encodeStatic(x, y);
188
+
189
+ EncodedLengths _encodedLengths;
190
+ bytes memory _dynamicData;
191
+
192
+ bytes32[] memory _keyTuple = new bytes32[](1);
193
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
194
+
195
+ StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
196
+ }
197
+
198
+ /**
199
+ * @notice Set the full data using individual values.
200
+ */
201
+ function _set(address player, int32 x, int32 y) internal {
202
+ bytes memory _staticData = encodeStatic(x, y);
203
+
204
+ EncodedLengths _encodedLengths;
205
+ bytes memory _dynamicData;
206
+
207
+ bytes32[] memory _keyTuple = new bytes32[](1);
208
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
209
+
210
+ StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
211
+ }
212
+
213
+ /**
214
+ * @notice Set the full data using the data struct.
215
+ */
216
+ function set(address player, PositionData memory _table) internal {
217
+ bytes memory _staticData = encodeStatic(_table.x, _table.y);
218
+
219
+ EncodedLengths _encodedLengths;
220
+ bytes memory _dynamicData;
221
+
222
+ bytes32[] memory _keyTuple = new bytes32[](1);
223
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
224
+
225
+ StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
226
+ }
227
+
228
+ /**
229
+ * @notice Set the full data using the data struct.
230
+ */
231
+ function _set(address player, PositionData memory _table) internal {
232
+ bytes memory _staticData = encodeStatic(_table.x, _table.y);
233
+
234
+ EncodedLengths _encodedLengths;
235
+ bytes memory _dynamicData;
236
+
237
+ bytes32[] memory _keyTuple = new bytes32[](1);
238
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
239
+
240
+ StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
241
+ }
242
+
243
+ /**
244
+ * @notice Decode the tightly packed blob of static data using this table's field layout.
245
+ */
246
+ function decodeStatic(bytes memory _blob) internal pure returns (int32 x, int32 y) {
247
+ x = (int32(uint32(Bytes.getBytes4(_blob, 0))));
248
+
249
+ y = (int32(uint32(Bytes.getBytes4(_blob, 4))));
250
+ }
251
+
252
+ /**
253
+ * @notice Decode the tightly packed blobs using this table's field layout.
254
+ * @param _staticData Tightly packed static fields.
255
+ *
256
+ *
257
+ */
258
+ function decode(
259
+ bytes memory _staticData,
260
+ EncodedLengths,
261
+ bytes memory
262
+ ) internal pure returns (PositionData memory _table) {
263
+ (_table.x, _table.y) = decodeStatic(_staticData);
264
+ }
265
+
266
+ /**
267
+ * @notice Delete all data for given keys.
268
+ */
269
+ function deleteRecord(address player) internal {
270
+ bytes32[] memory _keyTuple = new bytes32[](1);
271
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
272
+
273
+ StoreSwitch.deleteRecord(_tableId, _keyTuple);
274
+ }
275
+
276
+ /**
277
+ * @notice Delete all data for given keys.
278
+ */
279
+ function _deleteRecord(address player) internal {
280
+ bytes32[] memory _keyTuple = new bytes32[](1);
281
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
282
+
283
+ StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
284
+ }
285
+
286
+ /**
287
+ * @notice Tightly pack static (fixed length) data using this table's schema.
288
+ * @return The static data, encoded into a sequence of bytes.
289
+ */
290
+ function encodeStatic(int32 x, int32 y) internal pure returns (bytes memory) {
291
+ return abi.encodePacked(x, y);
292
+ }
293
+
294
+ /**
295
+ * @notice Encode all of a record's fields.
296
+ * @return The static (fixed length) data, encoded into a sequence of bytes.
297
+ * @return The lengths of the dynamic fields (packed into a single bytes32 value).
298
+ * @return The dynamic (variable length) data, encoded into a sequence of bytes.
299
+ */
300
+ function encode(int32 x, int32 y) internal pure returns (bytes memory, EncodedLengths, bytes memory) {
301
+ bytes memory _staticData = encodeStatic(x, y);
302
+
303
+ EncodedLengths _encodedLengths;
304
+ bytes memory _dynamicData;
305
+
306
+ return (_staticData, _encodedLengths, _dynamicData);
307
+ }
308
+
309
+ /**
310
+ * @notice Encode keys as a bytes32 array using this table's field layout.
311
+ */
312
+ function encodeKeyTuple(address player) internal pure returns (bytes32[] memory) {
313
+ bytes32[] memory _keyTuple = new bytes32[](1);
314
+ _keyTuple[0] = bytes32(uint256(uint160(player)));
315
+
316
+ return _keyTuple;
317
+ }
318
+ }
@@ -3,11 +3,13 @@ pragma solidity >=0.8.24;
3
3
 
4
4
  /* Autogenerated file. Do not edit manually. */
5
5
 
6
+ import { Direction } from "../common.sol";
7
+
6
8
  /**
7
- * @title IIncrementSystem
9
+ * @title IMoveSystem
8
10
  * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
9
11
  * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
10
12
  */
11
- interface IIncrementSystem {
12
- function app__increment() external returns (uint32);
13
+ interface IMoveSystem {
14
+ function app__move(Direction direction) external;
13
15
  }
@@ -4,7 +4,7 @@ pragma solidity >=0.8.24;
4
4
  /* Autogenerated file. Do not edit manually. */
5
5
 
6
6
  import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
7
- import { ITasksSystem } from "./ITasksSystem.sol";
7
+ import { IMoveSystem } from "./IMoveSystem.sol";
8
8
 
9
9
  /**
10
10
  * @title IWorld
@@ -13,4 +13,4 @@ import { ITasksSystem } from "./ITasksSystem.sol";
13
13
  * that are dynamically registered in the World during deployment.
14
14
  * @dev This is an autogenerated file; do not edit manually.
15
15
  */
16
- interface IWorld is IBaseWorld, ITasksSystem {}
16
+ interface IWorld is IBaseWorld, IMoveSystem {}
@@ -0,0 +1,25 @@
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
+
7
+ import { IWorld } from "../src/codegen/world/IWorld.sol";
8
+ import { Position, PositionData } from "../src/codegen/tables/Position.sol";
9
+ import { Direction } from "../src/codegen/common.sol";
10
+
11
+ contract MoveTest is MudTest {
12
+ function testMove() public {
13
+ address alice = vm.addr(uint256(keccak256("alice")));
14
+ vm.startPrank(alice);
15
+
16
+ PositionData memory position = Position.get(alice);
17
+ assertEq(position.x, 0);
18
+ assertEq(position.y, 0);
19
+
20
+ IWorld(worldAddress).app__move(Direction.North);
21
+ position = Position.get(alice);
22
+ assertEq(position.x, 0);
23
+ assertEq(position.y, 1);
24
+ }
25
+ }
@@ -0,0 +1,16 @@
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
+
7
+ contract WorldTest is MudTest {
8
+ function testWorldDeployed() public {
9
+ uint256 codeSize;
10
+ address addr = worldAddress;
11
+ assembly {
12
+ codeSize := extcodesize(addr)
13
+ }
14
+ assertTrue(codeSize > 0);
15
+ }
16
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "31337": {
3
- "address": "0x8d8b6b8414e1e3dcfd4168561b9be6bd3bf6ec4b"
3
+ "address": "0xfDf868Ea710FfD8cd33b829c5AFf79eDd15EcD5f"
4
4
  }
5
- }
5
+ }
@@ -0,0 +1,16 @@
1
+ .DS_Store
2
+ logs
3
+ *.log
4
+
5
+ node_modules
6
+
7
+ .env.*
8
+
9
+ # foundry
10
+ cache
11
+ broadcast
12
+ out/*
13
+ !out/IWorld.sol
14
+ out/IWorld.sol/*
15
+ !out/IWorld.sol/IWorld.abi.json
16
+ !out/IWorld.sol/IWorld.abi.d.json.ts
@@ -1,3 +1,4 @@
1
+ scrollback: 10000
1
2
  procs:
2
3
  client:
3
4
  cwd: packages/client
@@ -5,9 +6,16 @@ procs:
5
6
  contracts:
6
7
  cwd: packages/contracts
7
8
  shell: pnpm mud dev-contracts --rpc http://127.0.0.1:8545
9
+ deploy-prereqs:
10
+ cwd: packages/contracts
11
+ shell: pnpm entrykit-deploy
12
+ env:
13
+ DEBUG: "mud:*"
14
+ # Anvil default account (0x70997970C51812dc3A010C7d01b50e0d17dc79C8)
15
+ PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
8
16
  anvil:
9
17
  cwd: packages/contracts
10
- shell: anvil --base-fee 0 --block-time 2
18
+ shell: anvil --block-time 2
11
19
  explorer:
12
20
  cwd: packages/contracts
13
21
  shell: pnpm explorer
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "mud-template-react-ecs",
2
+ "name": "mud-template-react",
3
3
  "private": true,
4
4
  "scripts": {
5
5
  "build": "pnpm recursive run build",
@@ -17,7 +17,6 @@
17
17
  "@latticexyz/explorer": "{{mud-version}}",
18
18
  "@latticexyz/store-indexer": "{{mud-version}}",
19
19
  "@types/debug": "4.1.7",
20
- "@types/node": "^18",
21
20
  "@typescript-eslint/eslint-plugin": "7.1.1",
22
21
  "@typescript-eslint/parser": "7.1.1",
23
22
  "eslint": "8.57.0",
@@ -1,9 +1,9 @@
1
- <!DOCTYPE html>
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 minimal MUD client</title>
6
+ <title>a MUD app</title>
7
7
  </head>
8
8
  <body>
9
9
  <div id="react-root"></div>
@@ -6,32 +6,39 @@
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "vite build",
9
- "dev": "wait-port localhost:8545 && vite",
9
+ "dev": "vite",
10
10
  "preview": "vite preview",
11
11
  "test": "tsc --noEmit"
12
12
  },
13
13
  "dependencies": {
14
14
  "@latticexyz/common": "{{mud-version}}",
15
- "@latticexyz/dev-tools": "{{mud-version}}",
15
+ "@latticexyz/entrykit": "{{mud-version}}",
16
+ "@latticexyz/explorer": "{{mud-version}}",
16
17
  "@latticexyz/react": "{{mud-version}}",
17
18
  "@latticexyz/recs": "{{mud-version}}",
18
19
  "@latticexyz/schema-type": "{{mud-version}}",
19
20
  "@latticexyz/store-sync": "{{mud-version}}",
20
21
  "@latticexyz/utils": "{{mud-version}}",
21
22
  "@latticexyz/world": "{{mud-version}}",
23
+ "@tanstack/react-query": "^5.63.0",
22
24
  "contracts": "workspace:*",
23
- "react": "^18.2.0",
24
- "react-dom": "^18.2.0",
25
- "rxjs": "7.5.5",
26
- "viem": "2.21.19"
25
+ "react": "18.2.0",
26
+ "react-dom": "18.2.0",
27
+ "react-error-boundary": "5.0.0",
28
+ "tailwind-merge": "^2.6.0",
29
+ "viem": "2.21.19",
30
+ "wagmi": "2.12.11"
27
31
  },
28
32
  "devDependencies": {
29
33
  "@types/react": "18.2.22",
30
34
  "@types/react-dom": "18.2.7",
31
- "@vitejs/plugin-react": "^3.1.0",
35
+ "@vitejs/plugin-react": "^4.3.4",
36
+ "autoprefixer": "^10.4.20",
32
37
  "eslint-plugin-react": "7.31.11",
33
38
  "eslint-plugin-react-hooks": "4.6.0",
34
- "vite": "^4.2.1",
35
- "wait-port": "^1.0.4"
39
+ "postcss": "^8.4.49",
40
+ "tailwindcss": "^3.4.17",
41
+ "vite": "^6.0.7",
42
+ "vite-plugin-mud": "{{mud-version}}"
36
43
  }
37
44
  }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };