create-mud 2.0.0-main-cc4f4246 → 2.0.0-main-252a1852
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/templates/phaser/packages/contracts/mud.config.ts +6 -4
- package/dist/templates/react/packages/client/src/App.tsx +2 -2
- package/dist/templates/react/packages/client/src/mud/createSystemCalls.ts +5 -5
- package/dist/templates/react/packages/contracts/mud.config.ts +5 -3
- package/dist/templates/react/packages/contracts/src/codegen/tables/Tasks.sol +63 -63
- package/dist/templates/react/packages/contracts/src/codegen/world/ITasksSystem.sol +4 -4
- package/dist/templates/react/packages/contracts/src/systems/TasksSystem.sol +9 -9
- package/dist/templates/react-ecs/packages/contracts/mud.config.ts +6 -4
- package/dist/templates/threejs/packages/contracts/mud.config.ts +5 -3
- package/dist/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +43 -43
- package/dist/templates/vanilla/packages/contracts/mud.config.ts +6 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var t=require("create-create-app"),s=require("path");var e={name:"create-mud",version:"2.0.0-main-
|
|
2
|
+
"use strict";var t=require("create-create-app"),s=require("path");var e={name:"create-mud",version:"2.0.0-main-252a1852",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 && ./scripts/copy-templates.sh",clean:"pnpm run clean:js","clean:js":"rimraf 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 && rimraf test-project","test:react":"dist/cli.js test-project --template react && rimraf test-project","test:react-ecs":"dist/cli.js test-project --template react-ecs && rimraf test-project","test:threejs":"dist/cli.js test-project --template threejs && rimraf test-project","test:vanilla":"dist/cli.js test-project --template vanilla && rimraf test-project"},dependencies:{"create-create-app":"git+https://github.com/holic/create-create-app#74376c59b48a04aabbe94d9cacfe9cb1cecccd63"},devDependencies:{"@types/node":"^18.15.11",tsup:"^6.7.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org"}};var c=(0,s.resolve)(__dirname,"..","dist","templates");(0,t.create)("create-mud",{templateRoot:c,defaultTemplate:"vanilla",defaultPackageManager:"pnpm",promptForDescription:!1,promptForAuthor:!1,promptForEmail:!1,promptForLicense:!1,promptForTemplate:!0,caveat:({answers:r,packageManager:a})=>`Done! Play in the MUD with \`cd ${r.name}\` and \`${a} run dev\``,extra:{"mud-version":{type:"input",describe:"The version of MUD packages to use, defaults to latest",default:e.version}}});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineWorld } from "@latticexyz/world/config/v2";
|
|
2
2
|
|
|
3
|
-
export default
|
|
3
|
+
export default defineWorld({
|
|
4
4
|
tables: {
|
|
5
5
|
Counter: {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
schema: {
|
|
7
|
+
value: "uint32",
|
|
8
|
+
},
|
|
9
|
+
key: [],
|
|
8
10
|
},
|
|
9
11
|
},
|
|
10
12
|
});
|
|
@@ -31,7 +31,7 @@ export const App = () => {
|
|
|
31
31
|
|
|
32
32
|
checkbox.disabled = true;
|
|
33
33
|
try {
|
|
34
|
-
await toggleTask(task.key.
|
|
34
|
+
await toggleTask(task.key.id);
|
|
35
35
|
} finally {
|
|
36
36
|
checkbox.disabled = false;
|
|
37
37
|
}
|
|
@@ -51,7 +51,7 @@ export const App = () => {
|
|
|
51
51
|
const button = event.currentTarget;
|
|
52
52
|
button.disabled = true;
|
|
53
53
|
try {
|
|
54
|
-
await deleteTask(task.key.
|
|
54
|
+
await deleteTask(task.key.id);
|
|
55
55
|
} finally {
|
|
56
56
|
button.disabled = false;
|
|
57
57
|
}
|
|
@@ -35,14 +35,14 @@ export function createSystemCalls(
|
|
|
35
35
|
await waitForTransaction(tx);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const toggleTask = async (
|
|
39
|
-
const isComplete = (useStore.getState().getValue(tables.Tasks, {
|
|
40
|
-
const tx = isComplete ? await worldContract.write.resetTask([
|
|
38
|
+
const toggleTask = async (id: Hex) => {
|
|
39
|
+
const isComplete = (useStore.getState().getValue(tables.Tasks, { id })?.completedAt ?? 0n) > 0n;
|
|
40
|
+
const tx = isComplete ? await worldContract.write.resetTask([id]) : await worldContract.write.completeTask([id]);
|
|
41
41
|
await waitForTransaction(tx);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const deleteTask = async (
|
|
45
|
-
const tx = await worldContract.write.deleteTask([
|
|
44
|
+
const deleteTask = async (id: Hex) => {
|
|
45
|
+
const tx = await worldContract.write.deleteTask([id]);
|
|
46
46
|
await waitForTransaction(tx);
|
|
47
47
|
};
|
|
48
48
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineWorld } from "@latticexyz/world/config/v2";
|
|
2
2
|
|
|
3
|
-
export default
|
|
3
|
+
export default defineWorld({
|
|
4
4
|
tables: {
|
|
5
5
|
Tasks: {
|
|
6
|
-
|
|
6
|
+
schema: {
|
|
7
|
+
id: "bytes32",
|
|
7
8
|
createdAt: "uint256",
|
|
8
9
|
completedAt: "uint256",
|
|
9
10
|
description: "string",
|
|
10
11
|
},
|
|
12
|
+
key: ["id"],
|
|
11
13
|
},
|
|
12
14
|
},
|
|
13
15
|
});
|
|
@@ -40,7 +40,7 @@ library Tasks {
|
|
|
40
40
|
*/
|
|
41
41
|
function getKeyNames() internal pure returns (string[] memory keyNames) {
|
|
42
42
|
keyNames = new string[](1);
|
|
43
|
-
keyNames[0] = "
|
|
43
|
+
keyNames[0] = "id";
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -71,9 +71,9 @@ library Tasks {
|
|
|
71
71
|
/**
|
|
72
72
|
* @notice Get createdAt.
|
|
73
73
|
*/
|
|
74
|
-
function getCreatedAt(bytes32
|
|
74
|
+
function getCreatedAt(bytes32 id) internal view returns (uint256 createdAt) {
|
|
75
75
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
76
|
-
_keyTuple[0] =
|
|
76
|
+
_keyTuple[0] = id;
|
|
77
77
|
|
|
78
78
|
bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
|
|
79
79
|
return (uint256(bytes32(_blob)));
|
|
@@ -82,9 +82,9 @@ library Tasks {
|
|
|
82
82
|
/**
|
|
83
83
|
* @notice Get createdAt.
|
|
84
84
|
*/
|
|
85
|
-
function _getCreatedAt(bytes32
|
|
85
|
+
function _getCreatedAt(bytes32 id) internal view returns (uint256 createdAt) {
|
|
86
86
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
87
|
-
_keyTuple[0] =
|
|
87
|
+
_keyTuple[0] = id;
|
|
88
88
|
|
|
89
89
|
bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
|
|
90
90
|
return (uint256(bytes32(_blob)));
|
|
@@ -93,9 +93,9 @@ library Tasks {
|
|
|
93
93
|
/**
|
|
94
94
|
* @notice Set createdAt.
|
|
95
95
|
*/
|
|
96
|
-
function setCreatedAt(bytes32
|
|
96
|
+
function setCreatedAt(bytes32 id, uint256 createdAt) internal {
|
|
97
97
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
98
|
-
_keyTuple[0] =
|
|
98
|
+
_keyTuple[0] = id;
|
|
99
99
|
|
|
100
100
|
StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout);
|
|
101
101
|
}
|
|
@@ -103,9 +103,9 @@ library Tasks {
|
|
|
103
103
|
/**
|
|
104
104
|
* @notice Set createdAt.
|
|
105
105
|
*/
|
|
106
|
-
function _setCreatedAt(bytes32
|
|
106
|
+
function _setCreatedAt(bytes32 id, uint256 createdAt) internal {
|
|
107
107
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
108
|
-
_keyTuple[0] =
|
|
108
|
+
_keyTuple[0] = id;
|
|
109
109
|
|
|
110
110
|
StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout);
|
|
111
111
|
}
|
|
@@ -113,9 +113,9 @@ library Tasks {
|
|
|
113
113
|
/**
|
|
114
114
|
* @notice Get completedAt.
|
|
115
115
|
*/
|
|
116
|
-
function getCompletedAt(bytes32
|
|
116
|
+
function getCompletedAt(bytes32 id) internal view returns (uint256 completedAt) {
|
|
117
117
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
118
|
-
_keyTuple[0] =
|
|
118
|
+
_keyTuple[0] = id;
|
|
119
119
|
|
|
120
120
|
bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
|
|
121
121
|
return (uint256(bytes32(_blob)));
|
|
@@ -124,9 +124,9 @@ library Tasks {
|
|
|
124
124
|
/**
|
|
125
125
|
* @notice Get completedAt.
|
|
126
126
|
*/
|
|
127
|
-
function _getCompletedAt(bytes32
|
|
127
|
+
function _getCompletedAt(bytes32 id) internal view returns (uint256 completedAt) {
|
|
128
128
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
129
|
-
_keyTuple[0] =
|
|
129
|
+
_keyTuple[0] = id;
|
|
130
130
|
|
|
131
131
|
bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
|
|
132
132
|
return (uint256(bytes32(_blob)));
|
|
@@ -135,9 +135,9 @@ library Tasks {
|
|
|
135
135
|
/**
|
|
136
136
|
* @notice Set completedAt.
|
|
137
137
|
*/
|
|
138
|
-
function setCompletedAt(bytes32
|
|
138
|
+
function setCompletedAt(bytes32 id, uint256 completedAt) internal {
|
|
139
139
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
140
|
-
_keyTuple[0] =
|
|
140
|
+
_keyTuple[0] = id;
|
|
141
141
|
|
|
142
142
|
StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((completedAt)), _fieldLayout);
|
|
143
143
|
}
|
|
@@ -145,9 +145,9 @@ library Tasks {
|
|
|
145
145
|
/**
|
|
146
146
|
* @notice Set completedAt.
|
|
147
147
|
*/
|
|
148
|
-
function _setCompletedAt(bytes32
|
|
148
|
+
function _setCompletedAt(bytes32 id, uint256 completedAt) internal {
|
|
149
149
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
150
|
-
_keyTuple[0] =
|
|
150
|
+
_keyTuple[0] = id;
|
|
151
151
|
|
|
152
152
|
StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((completedAt)), _fieldLayout);
|
|
153
153
|
}
|
|
@@ -155,9 +155,9 @@ library Tasks {
|
|
|
155
155
|
/**
|
|
156
156
|
* @notice Get description.
|
|
157
157
|
*/
|
|
158
|
-
function getDescription(bytes32
|
|
158
|
+
function getDescription(bytes32 id) internal view returns (string memory description) {
|
|
159
159
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
160
|
-
_keyTuple[0] =
|
|
160
|
+
_keyTuple[0] = id;
|
|
161
161
|
|
|
162
162
|
bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0);
|
|
163
163
|
return (string(_blob));
|
|
@@ -166,9 +166,9 @@ library Tasks {
|
|
|
166
166
|
/**
|
|
167
167
|
* @notice Get description.
|
|
168
168
|
*/
|
|
169
|
-
function _getDescription(bytes32
|
|
169
|
+
function _getDescription(bytes32 id) internal view returns (string memory description) {
|
|
170
170
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
171
|
-
_keyTuple[0] =
|
|
171
|
+
_keyTuple[0] = id;
|
|
172
172
|
|
|
173
173
|
bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0);
|
|
174
174
|
return (string(_blob));
|
|
@@ -177,9 +177,9 @@ library Tasks {
|
|
|
177
177
|
/**
|
|
178
178
|
* @notice Set description.
|
|
179
179
|
*/
|
|
180
|
-
function setDescription(bytes32
|
|
180
|
+
function setDescription(bytes32 id, string memory description) internal {
|
|
181
181
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
182
|
-
_keyTuple[0] =
|
|
182
|
+
_keyTuple[0] = id;
|
|
183
183
|
|
|
184
184
|
StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, bytes((description)));
|
|
185
185
|
}
|
|
@@ -187,9 +187,9 @@ library Tasks {
|
|
|
187
187
|
/**
|
|
188
188
|
* @notice Set description.
|
|
189
189
|
*/
|
|
190
|
-
function _setDescription(bytes32
|
|
190
|
+
function _setDescription(bytes32 id, string memory description) internal {
|
|
191
191
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
192
|
-
_keyTuple[0] =
|
|
192
|
+
_keyTuple[0] = id;
|
|
193
193
|
|
|
194
194
|
StoreCore.setDynamicField(_tableId, _keyTuple, 0, bytes((description)));
|
|
195
195
|
}
|
|
@@ -197,9 +197,9 @@ library Tasks {
|
|
|
197
197
|
/**
|
|
198
198
|
* @notice Get the length of description.
|
|
199
199
|
*/
|
|
200
|
-
function lengthDescription(bytes32
|
|
200
|
+
function lengthDescription(bytes32 id) internal view returns (uint256) {
|
|
201
201
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
202
|
-
_keyTuple[0] =
|
|
202
|
+
_keyTuple[0] = id;
|
|
203
203
|
|
|
204
204
|
uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0);
|
|
205
205
|
unchecked {
|
|
@@ -210,9 +210,9 @@ library Tasks {
|
|
|
210
210
|
/**
|
|
211
211
|
* @notice Get the length of description.
|
|
212
212
|
*/
|
|
213
|
-
function _lengthDescription(bytes32
|
|
213
|
+
function _lengthDescription(bytes32 id) internal view returns (uint256) {
|
|
214
214
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
215
|
-
_keyTuple[0] =
|
|
215
|
+
_keyTuple[0] = id;
|
|
216
216
|
|
|
217
217
|
uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0);
|
|
218
218
|
unchecked {
|
|
@@ -224,9 +224,9 @@ library Tasks {
|
|
|
224
224
|
* @notice Get an item of description.
|
|
225
225
|
* @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
|
|
226
226
|
*/
|
|
227
|
-
function getItemDescription(bytes32
|
|
227
|
+
function getItemDescription(bytes32 id, uint256 _index) internal view returns (string memory) {
|
|
228
228
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
229
|
-
_keyTuple[0] =
|
|
229
|
+
_keyTuple[0] = id;
|
|
230
230
|
|
|
231
231
|
unchecked {
|
|
232
232
|
bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1);
|
|
@@ -238,9 +238,9 @@ library Tasks {
|
|
|
238
238
|
* @notice Get an item of description.
|
|
239
239
|
* @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
|
|
240
240
|
*/
|
|
241
|
-
function _getItemDescription(bytes32
|
|
241
|
+
function _getItemDescription(bytes32 id, uint256 _index) internal view returns (string memory) {
|
|
242
242
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
243
|
-
_keyTuple[0] =
|
|
243
|
+
_keyTuple[0] = id;
|
|
244
244
|
|
|
245
245
|
unchecked {
|
|
246
246
|
bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1);
|
|
@@ -251,9 +251,9 @@ library Tasks {
|
|
|
251
251
|
/**
|
|
252
252
|
* @notice Push a slice to description.
|
|
253
253
|
*/
|
|
254
|
-
function pushDescription(bytes32
|
|
254
|
+
function pushDescription(bytes32 id, string memory _slice) internal {
|
|
255
255
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
256
|
-
_keyTuple[0] =
|
|
256
|
+
_keyTuple[0] = id;
|
|
257
257
|
|
|
258
258
|
StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice)));
|
|
259
259
|
}
|
|
@@ -261,9 +261,9 @@ library Tasks {
|
|
|
261
261
|
/**
|
|
262
262
|
* @notice Push a slice to description.
|
|
263
263
|
*/
|
|
264
|
-
function _pushDescription(bytes32
|
|
264
|
+
function _pushDescription(bytes32 id, string memory _slice) internal {
|
|
265
265
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
266
|
-
_keyTuple[0] =
|
|
266
|
+
_keyTuple[0] = id;
|
|
267
267
|
|
|
268
268
|
StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice)));
|
|
269
269
|
}
|
|
@@ -271,9 +271,9 @@ library Tasks {
|
|
|
271
271
|
/**
|
|
272
272
|
* @notice Pop a slice from description.
|
|
273
273
|
*/
|
|
274
|
-
function popDescription(bytes32
|
|
274
|
+
function popDescription(bytes32 id) internal {
|
|
275
275
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
276
|
-
_keyTuple[0] =
|
|
276
|
+
_keyTuple[0] = id;
|
|
277
277
|
|
|
278
278
|
StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1);
|
|
279
279
|
}
|
|
@@ -281,9 +281,9 @@ library Tasks {
|
|
|
281
281
|
/**
|
|
282
282
|
* @notice Pop a slice from description.
|
|
283
283
|
*/
|
|
284
|
-
function _popDescription(bytes32
|
|
284
|
+
function _popDescription(bytes32 id) internal {
|
|
285
285
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
286
|
-
_keyTuple[0] =
|
|
286
|
+
_keyTuple[0] = id;
|
|
287
287
|
|
|
288
288
|
StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1);
|
|
289
289
|
}
|
|
@@ -291,9 +291,9 @@ library Tasks {
|
|
|
291
291
|
/**
|
|
292
292
|
* @notice Update a slice of description at `_index`.
|
|
293
293
|
*/
|
|
294
|
-
function updateDescription(bytes32
|
|
294
|
+
function updateDescription(bytes32 id, uint256 _index, string memory _slice) internal {
|
|
295
295
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
296
|
-
_keyTuple[0] =
|
|
296
|
+
_keyTuple[0] = id;
|
|
297
297
|
|
|
298
298
|
unchecked {
|
|
299
299
|
bytes memory _encoded = bytes((_slice));
|
|
@@ -304,9 +304,9 @@ library Tasks {
|
|
|
304
304
|
/**
|
|
305
305
|
* @notice Update a slice of description at `_index`.
|
|
306
306
|
*/
|
|
307
|
-
function _updateDescription(bytes32
|
|
307
|
+
function _updateDescription(bytes32 id, uint256 _index, string memory _slice) internal {
|
|
308
308
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
309
|
-
_keyTuple[0] =
|
|
309
|
+
_keyTuple[0] = id;
|
|
310
310
|
|
|
311
311
|
unchecked {
|
|
312
312
|
bytes memory _encoded = bytes((_slice));
|
|
@@ -317,9 +317,9 @@ library Tasks {
|
|
|
317
317
|
/**
|
|
318
318
|
* @notice Get the full data.
|
|
319
319
|
*/
|
|
320
|
-
function get(bytes32
|
|
320
|
+
function get(bytes32 id) internal view returns (TasksData memory _table) {
|
|
321
321
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
322
|
-
_keyTuple[0] =
|
|
322
|
+
_keyTuple[0] = id;
|
|
323
323
|
|
|
324
324
|
(bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord(
|
|
325
325
|
_tableId,
|
|
@@ -332,9 +332,9 @@ library Tasks {
|
|
|
332
332
|
/**
|
|
333
333
|
* @notice Get the full data.
|
|
334
334
|
*/
|
|
335
|
-
function _get(bytes32
|
|
335
|
+
function _get(bytes32 id) internal view returns (TasksData memory _table) {
|
|
336
336
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
337
|
-
_keyTuple[0] =
|
|
337
|
+
_keyTuple[0] = id;
|
|
338
338
|
|
|
339
339
|
(bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord(
|
|
340
340
|
_tableId,
|
|
@@ -347,14 +347,14 @@ library Tasks {
|
|
|
347
347
|
/**
|
|
348
348
|
* @notice Set the full data using individual values.
|
|
349
349
|
*/
|
|
350
|
-
function set(bytes32
|
|
350
|
+
function set(bytes32 id, uint256 createdAt, uint256 completedAt, string memory description) internal {
|
|
351
351
|
bytes memory _staticData = encodeStatic(createdAt, completedAt);
|
|
352
352
|
|
|
353
353
|
PackedCounter _encodedLengths = encodeLengths(description);
|
|
354
354
|
bytes memory _dynamicData = encodeDynamic(description);
|
|
355
355
|
|
|
356
356
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
357
|
-
_keyTuple[0] =
|
|
357
|
+
_keyTuple[0] = id;
|
|
358
358
|
|
|
359
359
|
StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
|
|
360
360
|
}
|
|
@@ -362,14 +362,14 @@ library Tasks {
|
|
|
362
362
|
/**
|
|
363
363
|
* @notice Set the full data using individual values.
|
|
364
364
|
*/
|
|
365
|
-
function _set(bytes32
|
|
365
|
+
function _set(bytes32 id, uint256 createdAt, uint256 completedAt, string memory description) internal {
|
|
366
366
|
bytes memory _staticData = encodeStatic(createdAt, completedAt);
|
|
367
367
|
|
|
368
368
|
PackedCounter _encodedLengths = encodeLengths(description);
|
|
369
369
|
bytes memory _dynamicData = encodeDynamic(description);
|
|
370
370
|
|
|
371
371
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
372
|
-
_keyTuple[0] =
|
|
372
|
+
_keyTuple[0] = id;
|
|
373
373
|
|
|
374
374
|
StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
|
|
375
375
|
}
|
|
@@ -377,14 +377,14 @@ library Tasks {
|
|
|
377
377
|
/**
|
|
378
378
|
* @notice Set the full data using the data struct.
|
|
379
379
|
*/
|
|
380
|
-
function set(bytes32
|
|
380
|
+
function set(bytes32 id, TasksData memory _table) internal {
|
|
381
381
|
bytes memory _staticData = encodeStatic(_table.createdAt, _table.completedAt);
|
|
382
382
|
|
|
383
383
|
PackedCounter _encodedLengths = encodeLengths(_table.description);
|
|
384
384
|
bytes memory _dynamicData = encodeDynamic(_table.description);
|
|
385
385
|
|
|
386
386
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
387
|
-
_keyTuple[0] =
|
|
387
|
+
_keyTuple[0] = id;
|
|
388
388
|
|
|
389
389
|
StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
|
|
390
390
|
}
|
|
@@ -392,14 +392,14 @@ library Tasks {
|
|
|
392
392
|
/**
|
|
393
393
|
* @notice Set the full data using the data struct.
|
|
394
394
|
*/
|
|
395
|
-
function _set(bytes32
|
|
395
|
+
function _set(bytes32 id, TasksData memory _table) internal {
|
|
396
396
|
bytes memory _staticData = encodeStatic(_table.createdAt, _table.completedAt);
|
|
397
397
|
|
|
398
398
|
PackedCounter _encodedLengths = encodeLengths(_table.description);
|
|
399
399
|
bytes memory _dynamicData = encodeDynamic(_table.description);
|
|
400
400
|
|
|
401
401
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
402
|
-
_keyTuple[0] =
|
|
402
|
+
_keyTuple[0] = id;
|
|
403
403
|
|
|
404
404
|
StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
|
|
405
405
|
}
|
|
@@ -447,9 +447,9 @@ library Tasks {
|
|
|
447
447
|
/**
|
|
448
448
|
* @notice Delete all data for given keys.
|
|
449
449
|
*/
|
|
450
|
-
function deleteRecord(bytes32
|
|
450
|
+
function deleteRecord(bytes32 id) internal {
|
|
451
451
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
452
|
-
_keyTuple[0] =
|
|
452
|
+
_keyTuple[0] = id;
|
|
453
453
|
|
|
454
454
|
StoreSwitch.deleteRecord(_tableId, _keyTuple);
|
|
455
455
|
}
|
|
@@ -457,9 +457,9 @@ library Tasks {
|
|
|
457
457
|
/**
|
|
458
458
|
* @notice Delete all data for given keys.
|
|
459
459
|
*/
|
|
460
|
-
function _deleteRecord(bytes32
|
|
460
|
+
function _deleteRecord(bytes32 id) internal {
|
|
461
461
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
462
|
-
_keyTuple[0] =
|
|
462
|
+
_keyTuple[0] = id;
|
|
463
463
|
|
|
464
464
|
StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
|
|
465
465
|
}
|
|
@@ -513,9 +513,9 @@ library Tasks {
|
|
|
513
513
|
/**
|
|
514
514
|
* @notice Encode keys as a bytes32 array using this table's field layout.
|
|
515
515
|
*/
|
|
516
|
-
function encodeKeyTuple(bytes32
|
|
516
|
+
function encodeKeyTuple(bytes32 id) internal pure returns (bytes32[] memory) {
|
|
517
517
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
518
|
-
_keyTuple[0] =
|
|
518
|
+
_keyTuple[0] = id;
|
|
519
519
|
|
|
520
520
|
return _keyTuple;
|
|
521
521
|
}
|
|
@@ -9,11 +9,11 @@ pragma solidity >=0.8.24;
|
|
|
9
9
|
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
|
|
10
10
|
*/
|
|
11
11
|
interface ITasksSystem {
|
|
12
|
-
function addTask(string memory description) external returns (bytes32
|
|
12
|
+
function addTask(string memory description) external returns (bytes32 id);
|
|
13
13
|
|
|
14
|
-
function completeTask(bytes32
|
|
14
|
+
function completeTask(bytes32 id) external;
|
|
15
15
|
|
|
16
|
-
function resetTask(bytes32
|
|
16
|
+
function resetTask(bytes32 id) external;
|
|
17
17
|
|
|
18
|
-
function deleteTask(bytes32
|
|
18
|
+
function deleteTask(bytes32 id) external;
|
|
19
19
|
}
|
|
@@ -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
|
|
9
|
-
|
|
10
|
-
Tasks.set(
|
|
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
|
|
14
|
-
Tasks.setCompletedAt(
|
|
13
|
+
function completeTask(bytes32 id) public {
|
|
14
|
+
Tasks.setCompletedAt(id, block.timestamp);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function resetTask(bytes32
|
|
18
|
-
Tasks.setCompletedAt(
|
|
17
|
+
function resetTask(bytes32 id) public {
|
|
18
|
+
Tasks.setCompletedAt(id, 0);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function deleteTask(bytes32
|
|
22
|
-
Tasks.deleteRecord(
|
|
21
|
+
function deleteTask(bytes32 id) public {
|
|
22
|
+
Tasks.deleteRecord(id);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineWorld } from "@latticexyz/world/config/v2";
|
|
2
2
|
|
|
3
|
-
export default
|
|
3
|
+
export default defineWorld({
|
|
4
4
|
tables: {
|
|
5
5
|
Counter: {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
schema: {
|
|
7
|
+
value: "uint32",
|
|
8
|
+
},
|
|
9
|
+
key: [],
|
|
8
10
|
},
|
|
9
11
|
},
|
|
10
12
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineWorld } from "@latticexyz/world/config/v2";
|
|
2
2
|
|
|
3
|
-
export default
|
|
3
|
+
export default defineWorld({
|
|
4
4
|
tables: {
|
|
5
5
|
Position: {
|
|
6
|
-
|
|
6
|
+
schema: {
|
|
7
|
+
id: "bytes32",
|
|
7
8
|
x: "int32",
|
|
8
9
|
y: "int32",
|
|
9
10
|
z: "int32",
|
|
10
11
|
},
|
|
12
|
+
key: ["id"],
|
|
11
13
|
},
|
|
12
14
|
},
|
|
13
15
|
});
|
|
@@ -40,7 +40,7 @@ library Position {
|
|
|
40
40
|
*/
|
|
41
41
|
function getKeyNames() internal pure returns (string[] memory keyNames) {
|
|
42
42
|
keyNames = new string[](1);
|
|
43
|
-
keyNames[0] = "
|
|
43
|
+
keyNames[0] = "id";
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -71,9 +71,9 @@ library Position {
|
|
|
71
71
|
/**
|
|
72
72
|
* @notice Get x.
|
|
73
73
|
*/
|
|
74
|
-
function getX(bytes32
|
|
74
|
+
function getX(bytes32 id) internal view returns (int32 x) {
|
|
75
75
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
76
|
-
_keyTuple[0] =
|
|
76
|
+
_keyTuple[0] = id;
|
|
77
77
|
|
|
78
78
|
bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
|
|
79
79
|
return (int32(uint32(bytes4(_blob))));
|
|
@@ -82,9 +82,9 @@ library Position {
|
|
|
82
82
|
/**
|
|
83
83
|
* @notice Get x.
|
|
84
84
|
*/
|
|
85
|
-
function _getX(bytes32
|
|
85
|
+
function _getX(bytes32 id) internal view returns (int32 x) {
|
|
86
86
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
87
|
-
_keyTuple[0] =
|
|
87
|
+
_keyTuple[0] = id;
|
|
88
88
|
|
|
89
89
|
bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
|
|
90
90
|
return (int32(uint32(bytes4(_blob))));
|
|
@@ -93,9 +93,9 @@ library Position {
|
|
|
93
93
|
/**
|
|
94
94
|
* @notice Set x.
|
|
95
95
|
*/
|
|
96
|
-
function setX(bytes32
|
|
96
|
+
function setX(bytes32 id, int32 x) internal {
|
|
97
97
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
98
|
-
_keyTuple[0] =
|
|
98
|
+
_keyTuple[0] = id;
|
|
99
99
|
|
|
100
100
|
StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout);
|
|
101
101
|
}
|
|
@@ -103,9 +103,9 @@ library Position {
|
|
|
103
103
|
/**
|
|
104
104
|
* @notice Set x.
|
|
105
105
|
*/
|
|
106
|
-
function _setX(bytes32
|
|
106
|
+
function _setX(bytes32 id, int32 x) internal {
|
|
107
107
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
108
|
-
_keyTuple[0] =
|
|
108
|
+
_keyTuple[0] = id;
|
|
109
109
|
|
|
110
110
|
StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout);
|
|
111
111
|
}
|
|
@@ -113,9 +113,9 @@ library Position {
|
|
|
113
113
|
/**
|
|
114
114
|
* @notice Get y.
|
|
115
115
|
*/
|
|
116
|
-
function getY(bytes32
|
|
116
|
+
function getY(bytes32 id) internal view returns (int32 y) {
|
|
117
117
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
118
|
-
_keyTuple[0] =
|
|
118
|
+
_keyTuple[0] = id;
|
|
119
119
|
|
|
120
120
|
bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
|
|
121
121
|
return (int32(uint32(bytes4(_blob))));
|
|
@@ -124,9 +124,9 @@ library Position {
|
|
|
124
124
|
/**
|
|
125
125
|
* @notice Get y.
|
|
126
126
|
*/
|
|
127
|
-
function _getY(bytes32
|
|
127
|
+
function _getY(bytes32 id) internal view returns (int32 y) {
|
|
128
128
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
129
|
-
_keyTuple[0] =
|
|
129
|
+
_keyTuple[0] = id;
|
|
130
130
|
|
|
131
131
|
bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout);
|
|
132
132
|
return (int32(uint32(bytes4(_blob))));
|
|
@@ -135,9 +135,9 @@ library Position {
|
|
|
135
135
|
/**
|
|
136
136
|
* @notice Set y.
|
|
137
137
|
*/
|
|
138
|
-
function setY(bytes32
|
|
138
|
+
function setY(bytes32 id, int32 y) internal {
|
|
139
139
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
140
|
-
_keyTuple[0] =
|
|
140
|
+
_keyTuple[0] = id;
|
|
141
141
|
|
|
142
142
|
StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout);
|
|
143
143
|
}
|
|
@@ -145,9 +145,9 @@ library Position {
|
|
|
145
145
|
/**
|
|
146
146
|
* @notice Set y.
|
|
147
147
|
*/
|
|
148
|
-
function _setY(bytes32
|
|
148
|
+
function _setY(bytes32 id, int32 y) internal {
|
|
149
149
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
150
|
-
_keyTuple[0] =
|
|
150
|
+
_keyTuple[0] = id;
|
|
151
151
|
|
|
152
152
|
StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout);
|
|
153
153
|
}
|
|
@@ -155,9 +155,9 @@ library Position {
|
|
|
155
155
|
/**
|
|
156
156
|
* @notice Get z.
|
|
157
157
|
*/
|
|
158
|
-
function getZ(bytes32
|
|
158
|
+
function getZ(bytes32 id) internal view returns (int32 z) {
|
|
159
159
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
160
|
-
_keyTuple[0] =
|
|
160
|
+
_keyTuple[0] = id;
|
|
161
161
|
|
|
162
162
|
bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 2, _fieldLayout);
|
|
163
163
|
return (int32(uint32(bytes4(_blob))));
|
|
@@ -166,9 +166,9 @@ library Position {
|
|
|
166
166
|
/**
|
|
167
167
|
* @notice Get z.
|
|
168
168
|
*/
|
|
169
|
-
function _getZ(bytes32
|
|
169
|
+
function _getZ(bytes32 id) internal view returns (int32 z) {
|
|
170
170
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
171
|
-
_keyTuple[0] =
|
|
171
|
+
_keyTuple[0] = id;
|
|
172
172
|
|
|
173
173
|
bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 2, _fieldLayout);
|
|
174
174
|
return (int32(uint32(bytes4(_blob))));
|
|
@@ -177,9 +177,9 @@ library Position {
|
|
|
177
177
|
/**
|
|
178
178
|
* @notice Set z.
|
|
179
179
|
*/
|
|
180
|
-
function setZ(bytes32
|
|
180
|
+
function setZ(bytes32 id, int32 z) internal {
|
|
181
181
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
182
|
-
_keyTuple[0] =
|
|
182
|
+
_keyTuple[0] = id;
|
|
183
183
|
|
|
184
184
|
StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout);
|
|
185
185
|
}
|
|
@@ -187,9 +187,9 @@ library Position {
|
|
|
187
187
|
/**
|
|
188
188
|
* @notice Set z.
|
|
189
189
|
*/
|
|
190
|
-
function _setZ(bytes32
|
|
190
|
+
function _setZ(bytes32 id, int32 z) internal {
|
|
191
191
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
192
|
-
_keyTuple[0] =
|
|
192
|
+
_keyTuple[0] = id;
|
|
193
193
|
|
|
194
194
|
StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout);
|
|
195
195
|
}
|
|
@@ -197,9 +197,9 @@ library Position {
|
|
|
197
197
|
/**
|
|
198
198
|
* @notice Get the full data.
|
|
199
199
|
*/
|
|
200
|
-
function get(bytes32
|
|
200
|
+
function get(bytes32 id) internal view returns (PositionData memory _table) {
|
|
201
201
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
202
|
-
_keyTuple[0] =
|
|
202
|
+
_keyTuple[0] = id;
|
|
203
203
|
|
|
204
204
|
(bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord(
|
|
205
205
|
_tableId,
|
|
@@ -212,9 +212,9 @@ library Position {
|
|
|
212
212
|
/**
|
|
213
213
|
* @notice Get the full data.
|
|
214
214
|
*/
|
|
215
|
-
function _get(bytes32
|
|
215
|
+
function _get(bytes32 id) internal view returns (PositionData memory _table) {
|
|
216
216
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
217
|
-
_keyTuple[0] =
|
|
217
|
+
_keyTuple[0] = id;
|
|
218
218
|
|
|
219
219
|
(bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord(
|
|
220
220
|
_tableId,
|
|
@@ -227,14 +227,14 @@ library Position {
|
|
|
227
227
|
/**
|
|
228
228
|
* @notice Set the full data using individual values.
|
|
229
229
|
*/
|
|
230
|
-
function set(bytes32
|
|
230
|
+
function set(bytes32 id, int32 x, int32 y, int32 z) internal {
|
|
231
231
|
bytes memory _staticData = encodeStatic(x, y, z);
|
|
232
232
|
|
|
233
233
|
PackedCounter _encodedLengths;
|
|
234
234
|
bytes memory _dynamicData;
|
|
235
235
|
|
|
236
236
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
237
|
-
_keyTuple[0] =
|
|
237
|
+
_keyTuple[0] = id;
|
|
238
238
|
|
|
239
239
|
StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
|
|
240
240
|
}
|
|
@@ -242,14 +242,14 @@ library Position {
|
|
|
242
242
|
/**
|
|
243
243
|
* @notice Set the full data using individual values.
|
|
244
244
|
*/
|
|
245
|
-
function _set(bytes32
|
|
245
|
+
function _set(bytes32 id, int32 x, int32 y, int32 z) internal {
|
|
246
246
|
bytes memory _staticData = encodeStatic(x, y, z);
|
|
247
247
|
|
|
248
248
|
PackedCounter _encodedLengths;
|
|
249
249
|
bytes memory _dynamicData;
|
|
250
250
|
|
|
251
251
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
252
|
-
_keyTuple[0] =
|
|
252
|
+
_keyTuple[0] = id;
|
|
253
253
|
|
|
254
254
|
StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
|
|
255
255
|
}
|
|
@@ -257,14 +257,14 @@ library Position {
|
|
|
257
257
|
/**
|
|
258
258
|
* @notice Set the full data using the data struct.
|
|
259
259
|
*/
|
|
260
|
-
function set(bytes32
|
|
260
|
+
function set(bytes32 id, PositionData memory _table) internal {
|
|
261
261
|
bytes memory _staticData = encodeStatic(_table.x, _table.y, _table.z);
|
|
262
262
|
|
|
263
263
|
PackedCounter _encodedLengths;
|
|
264
264
|
bytes memory _dynamicData;
|
|
265
265
|
|
|
266
266
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
267
|
-
_keyTuple[0] =
|
|
267
|
+
_keyTuple[0] = id;
|
|
268
268
|
|
|
269
269
|
StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
|
|
270
270
|
}
|
|
@@ -272,14 +272,14 @@ library Position {
|
|
|
272
272
|
/**
|
|
273
273
|
* @notice Set the full data using the data struct.
|
|
274
274
|
*/
|
|
275
|
-
function _set(bytes32
|
|
275
|
+
function _set(bytes32 id, PositionData memory _table) internal {
|
|
276
276
|
bytes memory _staticData = encodeStatic(_table.x, _table.y, _table.z);
|
|
277
277
|
|
|
278
278
|
PackedCounter _encodedLengths;
|
|
279
279
|
bytes memory _dynamicData;
|
|
280
280
|
|
|
281
281
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
282
|
-
_keyTuple[0] =
|
|
282
|
+
_keyTuple[0] = id;
|
|
283
283
|
|
|
284
284
|
StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
|
|
285
285
|
}
|
|
@@ -312,9 +312,9 @@ library Position {
|
|
|
312
312
|
/**
|
|
313
313
|
* @notice Delete all data for given keys.
|
|
314
314
|
*/
|
|
315
|
-
function deleteRecord(bytes32
|
|
315
|
+
function deleteRecord(bytes32 id) internal {
|
|
316
316
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
317
|
-
_keyTuple[0] =
|
|
317
|
+
_keyTuple[0] = id;
|
|
318
318
|
|
|
319
319
|
StoreSwitch.deleteRecord(_tableId, _keyTuple);
|
|
320
320
|
}
|
|
@@ -322,9 +322,9 @@ library Position {
|
|
|
322
322
|
/**
|
|
323
323
|
* @notice Delete all data for given keys.
|
|
324
324
|
*/
|
|
325
|
-
function _deleteRecord(bytes32
|
|
325
|
+
function _deleteRecord(bytes32 id) internal {
|
|
326
326
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
327
|
-
_keyTuple[0] =
|
|
327
|
+
_keyTuple[0] = id;
|
|
328
328
|
|
|
329
329
|
StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
|
|
330
330
|
}
|
|
@@ -355,9 +355,9 @@ library Position {
|
|
|
355
355
|
/**
|
|
356
356
|
* @notice Encode keys as a bytes32 array using this table's field layout.
|
|
357
357
|
*/
|
|
358
|
-
function encodeKeyTuple(bytes32
|
|
358
|
+
function encodeKeyTuple(bytes32 id) internal pure returns (bytes32[] memory) {
|
|
359
359
|
bytes32[] memory _keyTuple = new bytes32[](1);
|
|
360
|
-
_keyTuple[0] =
|
|
360
|
+
_keyTuple[0] = id;
|
|
361
361
|
|
|
362
362
|
return _keyTuple;
|
|
363
363
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineWorld } from "@latticexyz/world/config/v2";
|
|
2
2
|
|
|
3
|
-
export default
|
|
3
|
+
export default defineWorld({
|
|
4
4
|
tables: {
|
|
5
5
|
Counter: {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
schema: {
|
|
7
|
+
value: "uint32",
|
|
8
|
+
},
|
|
9
|
+
key: [],
|
|
8
10
|
},
|
|
9
11
|
},
|
|
10
12
|
});
|