create-mud 2.0.0-transaction-context-324984c5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/templates/phaser/.vscode/extensions.json +1 -1
  3. package/dist/templates/phaser/.vscode/settings.json +3 -1
  4. package/dist/templates/phaser/package.json +4 -5
  5. package/dist/templates/phaser/packages/art/package.json +1 -1
  6. package/dist/templates/phaser/packages/client/package.json +2 -2
  7. package/dist/templates/phaser/packages/client/src/mud/createSystemCalls.ts +1 -1
  8. package/dist/templates/phaser/packages/client/src/mud/setupNetwork.ts +23 -12
  9. package/dist/templates/phaser/packages/client/src/ui/App.tsx +1 -1
  10. package/dist/templates/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx +2 -2
  11. package/dist/templates/phaser/packages/contracts/mud.config.ts +6 -4
  12. package/dist/templates/phaser/packages/contracts/package.json +2 -2
  13. package/dist/templates/phaser/packages/contracts/src/codegen/index.sol +1 -1
  14. package/dist/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +15 -44
  15. package/dist/templates/phaser/packages/contracts/src/codegen/world/IIncrementSystem.sol +1 -0
  16. package/dist/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol +2 -3
  17. package/dist/templates/phaser/packages/contracts/test/CounterTest.t.sol +1 -1
  18. package/dist/templates/react/.vscode/extensions.json +1 -1
  19. package/dist/templates/react/.vscode/settings.json +3 -1
  20. package/dist/templates/react/package.json +4 -5
  21. package/dist/templates/react/packages/client/package.json +1 -1
  22. package/dist/templates/react/packages/client/src/App.tsx +2 -2
  23. package/dist/templates/react/packages/client/src/index.tsx +1 -1
  24. package/dist/templates/react/packages/client/src/mud/createSystemCalls.ts +6 -6
  25. package/dist/templates/react/packages/client/src/mud/setupNetwork.ts +23 -12
  26. package/dist/templates/react/packages/contracts/mud.config.ts +5 -3
  27. package/dist/templates/react/packages/contracts/package.json +2 -2
  28. package/dist/templates/react/packages/contracts/src/codegen/index.sol +1 -1
  29. package/dist/templates/react/packages/contracts/src/codegen/tables/Tasks.sol +90 -122
  30. package/dist/templates/react/packages/contracts/src/codegen/world/ITasksSystem.sol +5 -4
  31. package/dist/templates/react/packages/contracts/src/codegen/world/IWorld.sol +2 -3
  32. package/dist/templates/react/packages/contracts/src/systems/TasksSystem.sol +9 -9
  33. package/dist/templates/react-ecs/.vscode/extensions.json +1 -1
  34. package/dist/templates/react-ecs/.vscode/settings.json +3 -1
  35. package/dist/templates/react-ecs/package.json +4 -5
  36. package/dist/templates/react-ecs/packages/client/package.json +1 -1
  37. package/dist/templates/react-ecs/packages/client/src/index.tsx +1 -1
  38. package/dist/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts +1 -1
  39. package/dist/templates/react-ecs/packages/client/src/mud/setupNetwork.ts +23 -12
  40. package/dist/templates/react-ecs/packages/contracts/mud.config.ts +6 -4
  41. package/dist/templates/react-ecs/packages/contracts/package.json +2 -2
  42. package/dist/templates/react-ecs/packages/contracts/src/codegen/index.sol +1 -1
  43. package/dist/templates/react-ecs/packages/contracts/src/codegen/tables/Counter.sol +15 -44
  44. package/dist/templates/react-ecs/packages/contracts/src/codegen/world/IIncrementSystem.sol +1 -0
  45. package/dist/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol +2 -3
  46. package/dist/templates/react-ecs/packages/contracts/test/CounterTest.t.sol +1 -1
  47. package/dist/templates/threejs/.vscode/extensions.json +1 -1
  48. package/dist/templates/threejs/.vscode/settings.json +3 -1
  49. package/dist/templates/threejs/package.json +4 -5
  50. package/dist/templates/threejs/packages/client/package.json +1 -1
  51. package/dist/templates/threejs/packages/client/src/index.tsx +1 -1
  52. package/dist/templates/threejs/packages/client/src/mud/createSystemCalls.ts +1 -1
  53. package/dist/templates/threejs/packages/client/src/mud/setupNetwork.ts +23 -12
  54. package/dist/templates/threejs/packages/contracts/mud.config.ts +5 -3
  55. package/dist/templates/threejs/packages/contracts/package.json +2 -2
  56. package/dist/templates/threejs/packages/contracts/src/codegen/index.sol +1 -1
  57. package/dist/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +68 -100
  58. package/dist/templates/threejs/packages/contracts/src/codegen/world/IMoveSystem.sol +1 -0
  59. package/dist/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol +2 -3
  60. package/dist/templates/vanilla/.vscode/extensions.json +1 -1
  61. package/dist/templates/vanilla/.vscode/settings.json +3 -1
  62. package/dist/templates/vanilla/package.json +4 -5
  63. package/dist/templates/vanilla/packages/client/package.json +1 -1
  64. package/dist/templates/vanilla/packages/client/src/mud/createSystemCalls.ts +1 -1
  65. package/dist/templates/vanilla/packages/client/src/mud/setupNetwork.ts +23 -12
  66. package/dist/templates/vanilla/packages/contracts/mud.config.ts +6 -4
  67. package/dist/templates/vanilla/packages/contracts/package.json +2 -2
  68. package/dist/templates/vanilla/packages/contracts/src/codegen/index.sol +1 -1
  69. package/dist/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +15 -44
  70. package/dist/templates/vanilla/packages/contracts/src/codegen/world/IIncrementSystem.sol +1 -0
  71. package/dist/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol +2 -3
  72. package/dist/templates/vanilla/packages/contracts/test/CounterTest.t.sol +1 -1
  73. package/package.json +1 -2
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
3
3
 
4
4
  /* Autogenerated file. Do not edit manually. */
5
5
 
6
- // Import schema type
7
- import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
8
-
9
6
  // Import store internals
10
7
  import { IStore } from "@latticexyz/store/src/IStore.sol";
11
8
  import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,19 +11,11 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
14
11
  import { Memory } from "@latticexyz/store/src/Memory.sol";
15
12
  import { SliceLib } from "@latticexyz/store/src/Slice.sol";
16
13
  import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
17
- import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
18
- import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
19
- import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.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";
20
17
  import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
21
18
 
22
- // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Tasks", typeId: RESOURCE_TABLE });`
23
- ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000005461736b730000000000000000000000);
24
- ResourceId constant TasksTableId = _tableId;
25
-
26
- FieldLayout constant _fieldLayout = FieldLayout.wrap(
27
- 0x0040020120200000000000000000000000000000000000000000000000000000
28
- );
29
-
30
19
  struct TasksData {
31
20
  uint256 createdAt;
32
21
  uint256 completedAt;
@@ -34,37 +23,16 @@ struct TasksData {
34
23
  }
35
24
 
36
25
  library Tasks {
37
- /**
38
- * @notice Get the table values' field layout.
39
- * @return _fieldLayout The field layout for the table.
40
- */
41
- function getFieldLayout() internal pure returns (FieldLayout) {
42
- return _fieldLayout;
43
- }
44
-
45
- /**
46
- * @notice Get the table's key schema.
47
- * @return _keySchema The key schema for the table.
48
- */
49
- function getKeySchema() internal pure returns (Schema) {
50
- SchemaType[] memory _keySchema = new SchemaType[](1);
51
- _keySchema[0] = SchemaType.BYTES32;
26
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Tasks", typeId: RESOURCE_TABLE });`
27
+ ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000005461736b730000000000000000000000);
52
28
 
53
- return SchemaLib.encode(_keySchema);
54
- }
29
+ FieldLayout constant _fieldLayout =
30
+ FieldLayout.wrap(0x0040020120200000000000000000000000000000000000000000000000000000);
55
31
 
56
- /**
57
- * @notice Get the table's value schema.
58
- * @return _valueSchema The value schema for the table.
59
- */
60
- function getValueSchema() internal pure returns (Schema) {
61
- SchemaType[] memory _valueSchema = new SchemaType[](3);
62
- _valueSchema[0] = SchemaType.UINT256;
63
- _valueSchema[1] = SchemaType.UINT256;
64
- _valueSchema[2] = SchemaType.STRING;
65
-
66
- return SchemaLib.encode(_valueSchema);
67
- }
32
+ // Hex-encoded key schema of (bytes32)
33
+ Schema constant _keySchema = Schema.wrap(0x002001005f000000000000000000000000000000000000000000000000000000);
34
+ // Hex-encoded value schema of (uint256, uint256, string)
35
+ Schema constant _valueSchema = Schema.wrap(0x004002011f1fc500000000000000000000000000000000000000000000000000);
68
36
 
69
37
  /**
70
38
  * @notice Get the table's key field names.
@@ -72,7 +40,7 @@ library Tasks {
72
40
  */
73
41
  function getKeyNames() internal pure returns (string[] memory keyNames) {
74
42
  keyNames = new string[](1);
75
- keyNames[0] = "key";
43
+ keyNames[0] = "id";
76
44
  }
77
45
 
78
46
  /**
@@ -90,22 +58,22 @@ library Tasks {
90
58
  * @notice Register the table with its config.
91
59
  */
92
60
  function register() internal {
93
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
61
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
94
62
  }
95
63
 
96
64
  /**
97
65
  * @notice Register the table with its config.
98
66
  */
99
67
  function _register() internal {
100
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
68
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
101
69
  }
102
70
 
103
71
  /**
104
72
  * @notice Get createdAt.
105
73
  */
106
- function getCreatedAt(bytes32 key) internal view returns (uint256 createdAt) {
74
+ function getCreatedAt(bytes32 id) internal view returns (uint256 createdAt) {
107
75
  bytes32[] memory _keyTuple = new bytes32[](1);
108
- _keyTuple[0] = key;
76
+ _keyTuple[0] = id;
109
77
 
110
78
  bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
111
79
  return (uint256(bytes32(_blob)));
@@ -114,9 +82,9 @@ library Tasks {
114
82
  /**
115
83
  * @notice Get createdAt.
116
84
  */
117
- function _getCreatedAt(bytes32 key) internal view returns (uint256 createdAt) {
85
+ function _getCreatedAt(bytes32 id) internal view returns (uint256 createdAt) {
118
86
  bytes32[] memory _keyTuple = new bytes32[](1);
119
- _keyTuple[0] = key;
87
+ _keyTuple[0] = id;
120
88
 
121
89
  bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
122
90
  return (uint256(bytes32(_blob)));
@@ -125,9 +93,9 @@ library Tasks {
125
93
  /**
126
94
  * @notice Set createdAt.
127
95
  */
128
- function setCreatedAt(bytes32 key, uint256 createdAt) internal {
96
+ function setCreatedAt(bytes32 id, uint256 createdAt) internal {
129
97
  bytes32[] memory _keyTuple = new bytes32[](1);
130
- _keyTuple[0] = key;
98
+ _keyTuple[0] = id;
131
99
 
132
100
  StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout);
133
101
  }
@@ -135,9 +103,9 @@ library Tasks {
135
103
  /**
136
104
  * @notice Set createdAt.
137
105
  */
138
- function _setCreatedAt(bytes32 key, uint256 createdAt) internal {
106
+ function _setCreatedAt(bytes32 id, uint256 createdAt) internal {
139
107
  bytes32[] memory _keyTuple = new bytes32[](1);
140
- _keyTuple[0] = key;
108
+ _keyTuple[0] = id;
141
109
 
142
110
  StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout);
143
111
  }
@@ -145,9 +113,9 @@ library Tasks {
145
113
  /**
146
114
  * @notice Get completedAt.
147
115
  */
148
- function getCompletedAt(bytes32 key) internal view returns (uint256 completedAt) {
116
+ function getCompletedAt(bytes32 id) internal view returns (uint256 completedAt) {
149
117
  bytes32[] memory _keyTuple = new bytes32[](1);
150
- _keyTuple[0] = key;
118
+ _keyTuple[0] = id;
151
119
 
152
120
  bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
153
121
  return (uint256(bytes32(_blob)));
@@ -156,9 +124,9 @@ library Tasks {
156
124
  /**
157
125
  * @notice Get completedAt.
158
126
  */
159
- function _getCompletedAt(bytes32 key) internal view returns (uint256 completedAt) {
127
+ function _getCompletedAt(bytes32 id) internal view returns (uint256 completedAt) {
160
128
  bytes32[] memory _keyTuple = new bytes32[](1);
161
- _keyTuple[0] = key;
129
+ _keyTuple[0] = id;
162
130
 
163
131
  bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
164
132
  return (uint256(bytes32(_blob)));
@@ -167,9 +135,9 @@ library Tasks {
167
135
  /**
168
136
  * @notice Set completedAt.
169
137
  */
170
- function setCompletedAt(bytes32 key, uint256 completedAt) internal {
138
+ function setCompletedAt(bytes32 id, uint256 completedAt) internal {
171
139
  bytes32[] memory _keyTuple = new bytes32[](1);
172
- _keyTuple[0] = key;
140
+ _keyTuple[0] = id;
173
141
 
174
142
  StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((completedAt)), _fieldLayout);
175
143
  }
@@ -177,9 +145,9 @@ library Tasks {
177
145
  /**
178
146
  * @notice Set completedAt.
179
147
  */
180
- function _setCompletedAt(bytes32 key, uint256 completedAt) internal {
148
+ function _setCompletedAt(bytes32 id, uint256 completedAt) internal {
181
149
  bytes32[] memory _keyTuple = new bytes32[](1);
182
- _keyTuple[0] = key;
150
+ _keyTuple[0] = id;
183
151
 
184
152
  StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((completedAt)), _fieldLayout);
185
153
  }
@@ -187,9 +155,9 @@ library Tasks {
187
155
  /**
188
156
  * @notice Get description.
189
157
  */
190
- function getDescription(bytes32 key) internal view returns (string memory description) {
158
+ function getDescription(bytes32 id) internal view returns (string memory description) {
191
159
  bytes32[] memory _keyTuple = new bytes32[](1);
192
- _keyTuple[0] = key;
160
+ _keyTuple[0] = id;
193
161
 
194
162
  bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0);
195
163
  return (string(_blob));
@@ -198,9 +166,9 @@ library Tasks {
198
166
  /**
199
167
  * @notice Get description.
200
168
  */
201
- function _getDescription(bytes32 key) internal view returns (string memory description) {
169
+ function _getDescription(bytes32 id) internal view returns (string memory description) {
202
170
  bytes32[] memory _keyTuple = new bytes32[](1);
203
- _keyTuple[0] = key;
171
+ _keyTuple[0] = id;
204
172
 
205
173
  bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0);
206
174
  return (string(_blob));
@@ -209,9 +177,9 @@ library Tasks {
209
177
  /**
210
178
  * @notice Set description.
211
179
  */
212
- function setDescription(bytes32 key, string memory description) internal {
180
+ function setDescription(bytes32 id, string memory description) internal {
213
181
  bytes32[] memory _keyTuple = new bytes32[](1);
214
- _keyTuple[0] = key;
182
+ _keyTuple[0] = id;
215
183
 
216
184
  StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, bytes((description)));
217
185
  }
@@ -219,9 +187,9 @@ library Tasks {
219
187
  /**
220
188
  * @notice Set description.
221
189
  */
222
- function _setDescription(bytes32 key, string memory description) internal {
190
+ function _setDescription(bytes32 id, string memory description) internal {
223
191
  bytes32[] memory _keyTuple = new bytes32[](1);
224
- _keyTuple[0] = key;
192
+ _keyTuple[0] = id;
225
193
 
226
194
  StoreCore.setDynamicField(_tableId, _keyTuple, 0, bytes((description)));
227
195
  }
@@ -229,9 +197,9 @@ library Tasks {
229
197
  /**
230
198
  * @notice Get the length of description.
231
199
  */
232
- function lengthDescription(bytes32 key) internal view returns (uint256) {
200
+ function lengthDescription(bytes32 id) internal view returns (uint256) {
233
201
  bytes32[] memory _keyTuple = new bytes32[](1);
234
- _keyTuple[0] = key;
202
+ _keyTuple[0] = id;
235
203
 
236
204
  uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0);
237
205
  unchecked {
@@ -242,9 +210,9 @@ library Tasks {
242
210
  /**
243
211
  * @notice Get the length of description.
244
212
  */
245
- function _lengthDescription(bytes32 key) internal view returns (uint256) {
213
+ function _lengthDescription(bytes32 id) internal view returns (uint256) {
246
214
  bytes32[] memory _keyTuple = new bytes32[](1);
247
- _keyTuple[0] = key;
215
+ _keyTuple[0] = id;
248
216
 
249
217
  uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0);
250
218
  unchecked {
@@ -256,9 +224,9 @@ library Tasks {
256
224
  * @notice Get an item of description.
257
225
  * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
258
226
  */
259
- function getItemDescription(bytes32 key, uint256 _index) internal view returns (string memory) {
227
+ function getItemDescription(bytes32 id, uint256 _index) internal view returns (string memory) {
260
228
  bytes32[] memory _keyTuple = new bytes32[](1);
261
- _keyTuple[0] = key;
229
+ _keyTuple[0] = id;
262
230
 
263
231
  unchecked {
264
232
  bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1);
@@ -270,9 +238,9 @@ library Tasks {
270
238
  * @notice Get an item of description.
271
239
  * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
272
240
  */
273
- function _getItemDescription(bytes32 key, uint256 _index) internal view returns (string memory) {
241
+ function _getItemDescription(bytes32 id, uint256 _index) internal view returns (string memory) {
274
242
  bytes32[] memory _keyTuple = new bytes32[](1);
275
- _keyTuple[0] = key;
243
+ _keyTuple[0] = id;
276
244
 
277
245
  unchecked {
278
246
  bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1);
@@ -283,9 +251,9 @@ library Tasks {
283
251
  /**
284
252
  * @notice Push a slice to description.
285
253
  */
286
- function pushDescription(bytes32 key, string memory _slice) internal {
254
+ function pushDescription(bytes32 id, string memory _slice) internal {
287
255
  bytes32[] memory _keyTuple = new bytes32[](1);
288
- _keyTuple[0] = key;
256
+ _keyTuple[0] = id;
289
257
 
290
258
  StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice)));
291
259
  }
@@ -293,9 +261,9 @@ library Tasks {
293
261
  /**
294
262
  * @notice Push a slice to description.
295
263
  */
296
- function _pushDescription(bytes32 key, string memory _slice) internal {
264
+ function _pushDescription(bytes32 id, string memory _slice) internal {
297
265
  bytes32[] memory _keyTuple = new bytes32[](1);
298
- _keyTuple[0] = key;
266
+ _keyTuple[0] = id;
299
267
 
300
268
  StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice)));
301
269
  }
@@ -303,9 +271,9 @@ library Tasks {
303
271
  /**
304
272
  * @notice Pop a slice from description.
305
273
  */
306
- function popDescription(bytes32 key) internal {
274
+ function popDescription(bytes32 id) internal {
307
275
  bytes32[] memory _keyTuple = new bytes32[](1);
308
- _keyTuple[0] = key;
276
+ _keyTuple[0] = id;
309
277
 
310
278
  StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1);
311
279
  }
@@ -313,9 +281,9 @@ library Tasks {
313
281
  /**
314
282
  * @notice Pop a slice from description.
315
283
  */
316
- function _popDescription(bytes32 key) internal {
284
+ function _popDescription(bytes32 id) internal {
317
285
  bytes32[] memory _keyTuple = new bytes32[](1);
318
- _keyTuple[0] = key;
286
+ _keyTuple[0] = id;
319
287
 
320
288
  StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1);
321
289
  }
@@ -323,9 +291,9 @@ library Tasks {
323
291
  /**
324
292
  * @notice Update a slice of description at `_index`.
325
293
  */
326
- function updateDescription(bytes32 key, uint256 _index, string memory _slice) internal {
294
+ function updateDescription(bytes32 id, uint256 _index, string memory _slice) internal {
327
295
  bytes32[] memory _keyTuple = new bytes32[](1);
328
- _keyTuple[0] = key;
296
+ _keyTuple[0] = id;
329
297
 
330
298
  unchecked {
331
299
  bytes memory _encoded = bytes((_slice));
@@ -336,9 +304,9 @@ library Tasks {
336
304
  /**
337
305
  * @notice Update a slice of description at `_index`.
338
306
  */
339
- function _updateDescription(bytes32 key, uint256 _index, string memory _slice) internal {
307
+ function _updateDescription(bytes32 id, uint256 _index, string memory _slice) internal {
340
308
  bytes32[] memory _keyTuple = new bytes32[](1);
341
- _keyTuple[0] = key;
309
+ _keyTuple[0] = id;
342
310
 
343
311
  unchecked {
344
312
  bytes memory _encoded = bytes((_slice));
@@ -349,11 +317,11 @@ library Tasks {
349
317
  /**
350
318
  * @notice Get the full data.
351
319
  */
352
- function get(bytes32 key) internal view returns (TasksData memory _table) {
320
+ function get(bytes32 id) internal view returns (TasksData memory _table) {
353
321
  bytes32[] memory _keyTuple = new bytes32[](1);
354
- _keyTuple[0] = key;
322
+ _keyTuple[0] = id;
355
323
 
356
- (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord(
324
+ (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord(
357
325
  _tableId,
358
326
  _keyTuple,
359
327
  _fieldLayout
@@ -364,11 +332,11 @@ library Tasks {
364
332
  /**
365
333
  * @notice Get the full data.
366
334
  */
367
- function _get(bytes32 key) internal view returns (TasksData memory _table) {
335
+ function _get(bytes32 id) internal view returns (TasksData memory _table) {
368
336
  bytes32[] memory _keyTuple = new bytes32[](1);
369
- _keyTuple[0] = key;
337
+ _keyTuple[0] = id;
370
338
 
371
- (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord(
339
+ (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord(
372
340
  _tableId,
373
341
  _keyTuple,
374
342
  _fieldLayout
@@ -379,14 +347,14 @@ library Tasks {
379
347
  /**
380
348
  * @notice Set the full data using individual values.
381
349
  */
382
- function set(bytes32 key, uint256 createdAt, uint256 completedAt, string memory description) internal {
350
+ function set(bytes32 id, uint256 createdAt, uint256 completedAt, string memory description) internal {
383
351
  bytes memory _staticData = encodeStatic(createdAt, completedAt);
384
352
 
385
- PackedCounter _encodedLengths = encodeLengths(description);
353
+ EncodedLengths _encodedLengths = encodeLengths(description);
386
354
  bytes memory _dynamicData = encodeDynamic(description);
387
355
 
388
356
  bytes32[] memory _keyTuple = new bytes32[](1);
389
- _keyTuple[0] = key;
357
+ _keyTuple[0] = id;
390
358
 
391
359
  StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
392
360
  }
@@ -394,14 +362,14 @@ library Tasks {
394
362
  /**
395
363
  * @notice Set the full data using individual values.
396
364
  */
397
- function _set(bytes32 key, uint256 createdAt, uint256 completedAt, string memory description) internal {
365
+ function _set(bytes32 id, uint256 createdAt, uint256 completedAt, string memory description) internal {
398
366
  bytes memory _staticData = encodeStatic(createdAt, completedAt);
399
367
 
400
- PackedCounter _encodedLengths = encodeLengths(description);
368
+ EncodedLengths _encodedLengths = encodeLengths(description);
401
369
  bytes memory _dynamicData = encodeDynamic(description);
402
370
 
403
371
  bytes32[] memory _keyTuple = new bytes32[](1);
404
- _keyTuple[0] = key;
372
+ _keyTuple[0] = id;
405
373
 
406
374
  StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
407
375
  }
@@ -409,14 +377,14 @@ library Tasks {
409
377
  /**
410
378
  * @notice Set the full data using the data struct.
411
379
  */
412
- function set(bytes32 key, TasksData memory _table) internal {
380
+ function set(bytes32 id, TasksData memory _table) internal {
413
381
  bytes memory _staticData = encodeStatic(_table.createdAt, _table.completedAt);
414
382
 
415
- PackedCounter _encodedLengths = encodeLengths(_table.description);
383
+ EncodedLengths _encodedLengths = encodeLengths(_table.description);
416
384
  bytes memory _dynamicData = encodeDynamic(_table.description);
417
385
 
418
386
  bytes32[] memory _keyTuple = new bytes32[](1);
419
- _keyTuple[0] = key;
387
+ _keyTuple[0] = id;
420
388
 
421
389
  StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
422
390
  }
@@ -424,14 +392,14 @@ library Tasks {
424
392
  /**
425
393
  * @notice Set the full data using the data struct.
426
394
  */
427
- function _set(bytes32 key, TasksData memory _table) internal {
395
+ function _set(bytes32 id, TasksData memory _table) internal {
428
396
  bytes memory _staticData = encodeStatic(_table.createdAt, _table.completedAt);
429
397
 
430
- PackedCounter _encodedLengths = encodeLengths(_table.description);
398
+ EncodedLengths _encodedLengths = encodeLengths(_table.description);
431
399
  bytes memory _dynamicData = encodeDynamic(_table.description);
432
400
 
433
401
  bytes32[] memory _keyTuple = new bytes32[](1);
434
- _keyTuple[0] = key;
402
+ _keyTuple[0] = id;
435
403
 
436
404
  StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
437
405
  }
@@ -440,16 +408,16 @@ library Tasks {
440
408
  * @notice Decode the tightly packed blob of static data using this table's field layout.
441
409
  */
442
410
  function decodeStatic(bytes memory _blob) internal pure returns (uint256 createdAt, uint256 completedAt) {
443
- createdAt = (uint256(Bytes.slice32(_blob, 0)));
411
+ createdAt = (uint256(Bytes.getBytes32(_blob, 0)));
444
412
 
445
- completedAt = (uint256(Bytes.slice32(_blob, 32)));
413
+ completedAt = (uint256(Bytes.getBytes32(_blob, 32)));
446
414
  }
447
415
 
448
416
  /**
449
417
  * @notice Decode the tightly packed blob of dynamic data using the encoded lengths.
450
418
  */
451
419
  function decodeDynamic(
452
- PackedCounter _encodedLengths,
420
+ EncodedLengths _encodedLengths,
453
421
  bytes memory _blob
454
422
  ) internal pure returns (string memory description) {
455
423
  uint256 _start;
@@ -468,7 +436,7 @@ library Tasks {
468
436
  */
469
437
  function decode(
470
438
  bytes memory _staticData,
471
- PackedCounter _encodedLengths,
439
+ EncodedLengths _encodedLengths,
472
440
  bytes memory _dynamicData
473
441
  ) internal pure returns (TasksData memory _table) {
474
442
  (_table.createdAt, _table.completedAt) = decodeStatic(_staticData);
@@ -479,9 +447,9 @@ library Tasks {
479
447
  /**
480
448
  * @notice Delete all data for given keys.
481
449
  */
482
- function deleteRecord(bytes32 key) internal {
450
+ function deleteRecord(bytes32 id) internal {
483
451
  bytes32[] memory _keyTuple = new bytes32[](1);
484
- _keyTuple[0] = key;
452
+ _keyTuple[0] = id;
485
453
 
486
454
  StoreSwitch.deleteRecord(_tableId, _keyTuple);
487
455
  }
@@ -489,9 +457,9 @@ library Tasks {
489
457
  /**
490
458
  * @notice Delete all data for given keys.
491
459
  */
492
- function _deleteRecord(bytes32 key) internal {
460
+ function _deleteRecord(bytes32 id) internal {
493
461
  bytes32[] memory _keyTuple = new bytes32[](1);
494
- _keyTuple[0] = key;
462
+ _keyTuple[0] = id;
495
463
 
496
464
  StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
497
465
  }
@@ -508,10 +476,10 @@ library Tasks {
508
476
  * @notice Tightly pack dynamic data lengths using this table's schema.
509
477
  * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value).
510
478
  */
511
- function encodeLengths(string memory description) internal pure returns (PackedCounter _encodedLengths) {
479
+ function encodeLengths(string memory description) internal pure returns (EncodedLengths _encodedLengths) {
512
480
  // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits
513
481
  unchecked {
514
- _encodedLengths = PackedCounterLib.pack(bytes(description).length);
482
+ _encodedLengths = EncodedLengthsLib.pack(bytes(description).length);
515
483
  }
516
484
  }
517
485
 
@@ -533,10 +501,10 @@ library Tasks {
533
501
  uint256 createdAt,
534
502
  uint256 completedAt,
535
503
  string memory description
536
- ) internal pure returns (bytes memory, PackedCounter, bytes memory) {
504
+ ) internal pure returns (bytes memory, EncodedLengths, bytes memory) {
537
505
  bytes memory _staticData = encodeStatic(createdAt, completedAt);
538
506
 
539
- PackedCounter _encodedLengths = encodeLengths(description);
507
+ EncodedLengths _encodedLengths = encodeLengths(description);
540
508
  bytes memory _dynamicData = encodeDynamic(description);
541
509
 
542
510
  return (_staticData, _encodedLengths, _dynamicData);
@@ -545,9 +513,9 @@ library Tasks {
545
513
  /**
546
514
  * @notice Encode keys as a bytes32 array using this table's field layout.
547
515
  */
548
- function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) {
516
+ function encodeKeyTuple(bytes32 id) internal pure returns (bytes32[] memory) {
549
517
  bytes32[] memory _keyTuple = new bytes32[](1);
550
- _keyTuple[0] = key;
518
+ _keyTuple[0] = id;
551
519
 
552
520
  return _keyTuple;
553
521
  }
@@ -5,14 +5,15 @@ pragma solidity >=0.8.24;
5
5
 
6
6
  /**
7
7
  * @title ITasksSystem
8
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
8
9
  * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
9
10
  */
10
11
  interface ITasksSystem {
11
- function addTask(string memory description) external returns (bytes32 key);
12
+ function addTask(string memory description) external returns (bytes32 id);
12
13
 
13
- function completeTask(bytes32 key) external;
14
+ function completeTask(bytes32 id) external;
14
15
 
15
- function resetTask(bytes32 key) external;
16
+ function resetTask(bytes32 id) external;
16
17
 
17
- function deleteTask(bytes32 key) external;
18
+ function deleteTask(bytes32 id) external;
18
19
  }
@@ -9,10 +9,9 @@ import { ITasksSystem } from "./ITasksSystem.sol";
9
9
 
10
10
  /**
11
11
  * @title IWorld
12
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
12
13
  * @notice This interface integrates all systems and associated function selectors
13
14
  * that are dynamically registered in the World during deployment.
14
15
  * @dev This is an autogenerated file; do not edit manually.
15
16
  */
16
- interface IWorld is IBaseWorld, ITasksSystem {
17
-
18
- }
17
+ interface IWorld is IBaseWorld, ITasksSystem {}
@@ -5,20 +5,20 @@ import { System } from "@latticexyz/world/src/System.sol";
5
5
  import { Tasks, TasksData } from "../codegen/index.sol";
6
6
 
7
7
  contract TasksSystem is System {
8
- function addTask(string memory description) public returns (bytes32 key) {
9
- key = keccak256(abi.encode(block.prevrandao, _msgSender(), description));
10
- Tasks.set(key, TasksData({ description: description, createdAt: block.timestamp, completedAt: 0 }));
8
+ function addTask(string memory description) public returns (bytes32 id) {
9
+ id = keccak256(abi.encode(block.prevrandao, _msgSender(), description));
10
+ Tasks.set(id, TasksData({ description: description, createdAt: block.timestamp, completedAt: 0 }));
11
11
  }
12
12
 
13
- function completeTask(bytes32 key) public {
14
- Tasks.setCompletedAt(key, block.timestamp);
13
+ function completeTask(bytes32 id) public {
14
+ Tasks.setCompletedAt(id, block.timestamp);
15
15
  }
16
16
 
17
- function resetTask(bytes32 key) public {
18
- Tasks.setCompletedAt(key, 0);
17
+ function resetTask(bytes32 id) public {
18
+ Tasks.setCompletedAt(id, 0);
19
19
  }
20
20
 
21
- function deleteTask(bytes32 key) public {
22
- Tasks.deleteRecord(key);
21
+ function deleteTask(bytes32 id) public {
22
+ Tasks.deleteRecord(id);
23
23
  }
24
24
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "recommendations": ["NomicFoundation.hardhat-solidity"]
2
+ "recommendations": ["NomicFoundation.hardhat-solidity", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
3
3
  }
@@ -1 +1,3 @@
1
- {}
1
+ {
2
+ "typescript.tsdk": "node_modules/typescript/lib"
3
+ }
@@ -14,13 +14,12 @@
14
14
  "devDependencies": {
15
15
  "@latticexyz/cli": "{{mud-version}}",
16
16
  "@types/debug": "4.1.7",
17
- "@types/prettier": "2.7.2",
18
- "@typescript-eslint/eslint-plugin": "5.46.1",
19
- "@typescript-eslint/parser": "5.46.1",
20
- "eslint": "8.29.0",
17
+ "@typescript-eslint/eslint-plugin": "7.1.1",
18
+ "@typescript-eslint/parser": "7.1.1",
19
+ "eslint": "8.57.0",
21
20
  "mprocs": "^0.6.4",
22
21
  "rimraf": "^3.0.2",
23
- "typescript": "5.1.6"
22
+ "typescript": "5.4.2"
24
23
  },
25
24
  "engines": {
26
25
  "node": "18.x",
@@ -24,7 +24,7 @@
24
24
  "react": "^18.2.0",
25
25
  "react-dom": "^18.2.0",
26
26
  "rxjs": "7.5.5",
27
- "viem": "1.14.0"
27
+ "viem": "2.7.12"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/react": "18.2.22",
@@ -13,7 +13,7 @@ setup().then(async (result) => {
13
13
  root.render(
14
14
  <MUDProvider value={result}>
15
15
  <App />
16
- </MUDProvider>
16
+ </MUDProvider>,
17
17
  );
18
18
 
19
19
  // https://vitejs.dev/guide/env-and-mode.html
@@ -31,7 +31,7 @@ export function createSystemCalls(
31
31
  * (https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L77-L83).
32
32
  */
33
33
  { worldContract, waitForTransaction }: SetupNetworkResult,
34
- { Counter }: ClientComponents
34
+ { Counter }: ClientComponents,
35
35
  ) {
36
36
  const increment = async () => {
37
37
  /*