create-mud 2.0.0-next.12 → 2.0.0-next.13
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/.vscode/extensions.json +1 -1
- package/dist/templates/phaser/.vscode/settings.json +1 -4
- package/dist/templates/phaser/mprocs.yaml +7 -0
- package/dist/templates/phaser/package.json +2 -2
- package/dist/templates/phaser/packages/contracts/.env +3 -0
- package/dist/templates/phaser/packages/contracts/remappings.txt +3 -3
- package/dist/templates/phaser/packages/contracts/script/PostDeploy.s.sol +5 -0
- package/dist/templates/react/.vscode/extensions.json +1 -1
- package/dist/templates/react/.vscode/settings.json +1 -4
- package/dist/templates/react/mprocs.yaml +7 -0
- package/dist/templates/react/package.json +2 -2
- package/dist/templates/react/packages/client/package.json +0 -1
- package/dist/templates/react/packages/client/src/App.tsx +93 -17
- package/dist/templates/react/packages/client/src/index.tsx +0 -1
- package/dist/templates/react/packages/client/src/mud/createSystemCalls.ts +18 -15
- package/dist/templates/react/packages/client/src/mud/setup.ts +1 -4
- package/dist/templates/react/packages/client/src/mud/setupNetwork.ts +4 -9
- package/dist/templates/react/packages/contracts/.env +3 -0
- package/dist/templates/react/packages/contracts/mud.config.ts +6 -3
- package/dist/templates/react/packages/contracts/remappings.txt +3 -3
- package/dist/templates/react/packages/contracts/script/PostDeploy.s.sol +13 -4
- package/dist/templates/react/packages/contracts/src/codegen/index.sol +1 -1
- package/dist/templates/react/packages/contracts/src/codegen/tables/Tasks.sol +556 -0
- package/dist/templates/react/packages/contracts/src/codegen/world/ITasksSystem.sol +18 -0
- package/dist/templates/react/packages/contracts/src/codegen/world/IWorld.sol +2 -2
- package/dist/templates/react/packages/contracts/src/systems/TasksSystem.sol +24 -0
- package/dist/templates/react/packages/contracts/test/TasksTest.t.sol +30 -0
- package/dist/templates/react/packages/contracts/worlds.json +1 -1
- package/dist/templates/react-ecs/.eslintrc +10 -0
- package/dist/templates/react-ecs/.gitattributes +3 -0
- package/dist/templates/react-ecs/.vscode/extensions.json +3 -0
- package/dist/templates/react-ecs/.vscode/settings.json +1 -0
- package/dist/templates/react-ecs/mprocs.yaml +7 -0
- package/dist/templates/react-ecs/package.json +27 -0
- package/dist/templates/react-ecs/packages/client/.env +1 -0
- package/dist/templates/react-ecs/packages/client/.eslintrc +7 -0
- package/dist/templates/react-ecs/packages/client/index.html +12 -0
- package/dist/templates/react-ecs/packages/client/package.json +38 -0
- package/dist/templates/react-ecs/packages/client/src/App.tsx +29 -0
- package/dist/templates/react-ecs/packages/client/src/MUDContext.tsx +21 -0
- package/dist/templates/react-ecs/packages/client/src/index.tsx +34 -0
- package/dist/templates/react-ecs/packages/client/src/mud/createSystemCalls.ts +51 -0
- package/dist/templates/react-ecs/packages/client/src/mud/getNetworkConfig.ts +91 -0
- package/dist/templates/react-ecs/packages/client/src/mud/setup.ts +21 -0
- package/dist/templates/react-ecs/packages/client/src/mud/setupNetwork.ts +125 -0
- package/dist/templates/react-ecs/packages/client/src/mud/supportedChains.ts +20 -0
- package/dist/templates/react-ecs/packages/client/tsconfig.json +19 -0
- package/dist/templates/react-ecs/packages/client/vite.config.ts +17 -0
- package/dist/templates/react-ecs/packages/contracts/.env +11 -0
- package/dist/templates/react-ecs/packages/contracts/.prettierrc +8 -0
- package/dist/templates/react-ecs/packages/contracts/.solhint.json +12 -0
- package/dist/templates/react-ecs/packages/contracts/foundry.toml +26 -0
- package/dist/templates/react-ecs/packages/contracts/mud.config.ts +10 -0
- package/dist/templates/react-ecs/packages/contracts/package.json +36 -0
- package/dist/templates/react-ecs/packages/contracts/remappings.txt +3 -0
- package/dist/templates/react-ecs/packages/contracts/script/PostDeploy.s.sol +29 -0
- package/dist/templates/react-ecs/packages/contracts/src/codegen/index.sol +6 -0
- package/dist/templates/react-ecs/packages/contracts/src/codegen/world/IWorld.sol +18 -0
- package/dist/templates/react-ecs/packages/contracts/tsconfig.json +13 -0
- package/dist/templates/react-ecs/packages/contracts/worlds.json +5 -0
- package/dist/templates/react-ecs/packages/contracts/worlds.json.d.ts +2 -0
- package/dist/templates/react-ecs/pnpm-workspace.yaml +2 -0
- package/dist/templates/threejs/.vscode/extensions.json +1 -1
- package/dist/templates/threejs/.vscode/settings.json +1 -4
- package/dist/templates/threejs/mprocs.yaml +7 -0
- package/dist/templates/threejs/package.json +2 -2
- package/dist/templates/threejs/packages/contracts/.env +3 -0
- package/dist/templates/threejs/packages/contracts/remappings.txt +3 -3
- package/dist/templates/vanilla/.vscode/extensions.json +1 -1
- package/dist/templates/vanilla/.vscode/settings.json +1 -4
- package/dist/templates/vanilla/mprocs.yaml +7 -0
- package/dist/templates/vanilla/package.json +2 -2
- package/dist/templates/vanilla/packages/contracts/.env +3 -0
- package/dist/templates/vanilla/packages/contracts/remappings.txt +3 -3
- package/dist/templates/vanilla/packages/contracts/script/PostDeploy.s.sol +5 -0
- package/package.json +3 -2
- package/dist/templates/phaser/.gitignore +0 -1
- package/dist/templates/phaser/packages/art/.gitignore +0 -0
- package/dist/templates/phaser/packages/client/.gitignore +0 -3
- package/dist/templates/phaser/packages/contracts/.gitignore +0 -9
- package/dist/templates/react/.gitignore +0 -1
- package/dist/templates/react/packages/client/.gitignore +0 -3
- package/dist/templates/react/packages/contracts/.gitignore +0 -9
- package/dist/templates/threejs/.gitignore +0 -1
- package/dist/templates/threejs/packages/client/.gitignore +0 -3
- package/dist/templates/threejs/packages/contracts/.gitignore +0 -9
- package/dist/templates/vanilla/.gitignore +0 -1
- package/dist/templates/vanilla/packages/client/.gitignore +0 -3
- package/dist/templates/vanilla/packages/contracts/.gitignore +0 -9
- /package/dist/templates/{react → react-ecs}/packages/client/src/mud/createClientComponents.ts +0 -0
- /package/dist/templates/{react → react-ecs}/packages/client/src/mud/world.ts +0 -0
- /package/dist/templates/{react → react-ecs}/packages/contracts/src/codegen/tables/Counter.sol +0 -0
- /package/dist/templates/{react → react-ecs}/packages/contracts/src/codegen/world/IIncrementSystem.sol +0 -0
- /package/dist/templates/{react → react-ecs}/packages/contracts/src/systems/IncrementSystem.sol +0 -0
- /package/dist/templates/{react → react-ecs}/packages/contracts/test/CounterTest.t.sol +0 -0
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-next.
|
|
2
|
+
"use strict";var t=require("create-create-app"),s=require("path");var e={name:"create-mud",version:"2.0.0-next.13",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"},gitHead:"914a1e0ae4a573d685841ca2ea921435057deb8f"};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}}});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "pnpm recursive run build",
|
|
6
|
-
"dev": "
|
|
6
|
+
"dev": "mprocs",
|
|
7
7
|
"dev:client": "pnpm --filter 'client' run dev",
|
|
8
8
|
"dev:contracts": "pnpm --filter 'contracts' dev",
|
|
9
9
|
"foundry:up": "curl -L https://foundry.paradigm.xyz | bash && bash $HOME/.foundry/bin/foundryup",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"@latticexyz/cli": "{{mud-version}}",
|
|
16
16
|
"@typescript-eslint/eslint-plugin": "5.46.1",
|
|
17
17
|
"@typescript-eslint/parser": "5.46.1",
|
|
18
|
-
"concurrently": "^8.0.1",
|
|
19
18
|
"eslint": "8.29.0",
|
|
19
|
+
"mprocs": "^0.6.4",
|
|
20
20
|
"rimraf": "^3.0.2",
|
|
21
21
|
"typescript": "5.1.6"
|
|
22
22
|
},
|
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
# your deployment enviroment, but we're including this here for ease of local
|
|
5
5
|
# development. Please do not commit changes to this file!
|
|
6
6
|
#
|
|
7
|
+
# Enable debug logs for MUD CLI
|
|
8
|
+
DEBUG=mud:*
|
|
9
|
+
#
|
|
7
10
|
# Anvil default private key:
|
|
8
11
|
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
ds-test
|
|
2
|
-
forge-std
|
|
3
|
-
@latticexyz
|
|
1
|
+
ds-test/=node_modules/ds-test/src/
|
|
2
|
+
forge-std/=node_modules/forge-std/src/
|
|
3
|
+
@latticexyz/=node_modules/@latticexyz/
|
|
@@ -3,10 +3,15 @@ pragma solidity >=0.8.21;
|
|
|
3
3
|
|
|
4
4
|
import { Script } from "forge-std/Script.sol";
|
|
5
5
|
import { console } from "forge-std/console.sol";
|
|
6
|
+
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
|
|
7
|
+
|
|
6
8
|
import { IWorld } from "../src/codegen/world/IWorld.sol";
|
|
7
9
|
|
|
8
10
|
contract PostDeploy is Script {
|
|
9
11
|
function run(address worldAddress) external {
|
|
12
|
+
// Specify a store so that you can use tables directly in PostDeploy
|
|
13
|
+
StoreSwitch.setStoreAddress(worldAddress);
|
|
14
|
+
|
|
10
15
|
// Load the private key from the `PRIVATE_KEY` environment variable (in .env)
|
|
11
16
|
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
|
|
12
17
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "pnpm recursive run build",
|
|
6
|
-
"dev": "
|
|
6
|
+
"dev": "mprocs",
|
|
7
7
|
"dev:client": "pnpm --filter 'client' run dev",
|
|
8
8
|
"dev:contracts": "pnpm --filter 'contracts' dev",
|
|
9
9
|
"foundry:up": "curl -L https://foundry.paradigm.xyz | bash && bash $HOME/.foundry/bin/foundryup",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"@latticexyz/cli": "{{mud-version}}",
|
|
16
16
|
"@typescript-eslint/eslint-plugin": "5.46.1",
|
|
17
17
|
"@typescript-eslint/parser": "5.46.1",
|
|
18
|
-
"concurrently": "^8.0.1",
|
|
19
18
|
"eslint": "8.29.0",
|
|
19
|
+
"mprocs": "^0.6.4",
|
|
20
20
|
"rimraf": "^3.0.2",
|
|
21
21
|
"typescript": "5.1.6"
|
|
22
22
|
},
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"@latticexyz/common": "{{mud-version}}",
|
|
15
15
|
"@latticexyz/dev-tools": "{{mud-version}}",
|
|
16
16
|
"@latticexyz/react": "{{mud-version}}",
|
|
17
|
-
"@latticexyz/recs": "{{mud-version}}",
|
|
18
17
|
"@latticexyz/schema-type": "{{mud-version}}",
|
|
19
18
|
"@latticexyz/services": "{{mud-version}}",
|
|
20
19
|
"@latticexyz/store-sync": "{{mud-version}}",
|
|
@@ -1,29 +1,105 @@
|
|
|
1
|
-
import { useComponentValue } from "@latticexyz/react";
|
|
2
1
|
import { useMUD } from "./MUDContext";
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
const styleUnset = { all: "unset" } as const;
|
|
4
4
|
|
|
5
5
|
export const App = () => {
|
|
6
6
|
const {
|
|
7
|
-
|
|
8
|
-
systemCalls: {
|
|
7
|
+
network: { tables, useStore },
|
|
8
|
+
systemCalls: { addTask, toggleTask, deleteTask },
|
|
9
9
|
} = useMUD();
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const tasks = useStore((state) => {
|
|
12
|
+
const records = Object.values(state.getRecords(tables.Tasks));
|
|
13
|
+
records.sort((a, b) => Number(a.value.createdAt - b.value.createdAt));
|
|
14
|
+
return records;
|
|
15
|
+
});
|
|
12
16
|
|
|
13
17
|
return (
|
|
14
18
|
<>
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
<table>
|
|
20
|
+
<tbody>
|
|
21
|
+
{tasks.map((task) => (
|
|
22
|
+
<tr key={task.id}>
|
|
23
|
+
<td align="right">
|
|
24
|
+
<input
|
|
25
|
+
type="checkbox"
|
|
26
|
+
checked={task.value.completedAt > 0n}
|
|
27
|
+
title={task.value.completedAt === 0n ? "Mark task as completed" : "Mark task as incomplete"}
|
|
28
|
+
onChange={async (event) => {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
const checkbox = event.currentTarget;
|
|
31
|
+
|
|
32
|
+
checkbox.disabled = true;
|
|
33
|
+
try {
|
|
34
|
+
await toggleTask(task.key.key);
|
|
35
|
+
} finally {
|
|
36
|
+
checkbox.disabled = false;
|
|
37
|
+
}
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
</td>
|
|
41
|
+
<td>{task.value.completedAt > 0n ? <s>{task.value.description}</s> : <>{task.value.description}</>}</td>
|
|
42
|
+
<td align="right">
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
title="Delete task"
|
|
46
|
+
style={styleUnset}
|
|
47
|
+
onClick={async (event) => {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
if (!window.confirm("Are you sure you want to delete this task?")) return;
|
|
50
|
+
|
|
51
|
+
const button = event.currentTarget;
|
|
52
|
+
button.disabled = true;
|
|
53
|
+
try {
|
|
54
|
+
await deleteTask(task.key.key);
|
|
55
|
+
} finally {
|
|
56
|
+
button.disabled = false;
|
|
57
|
+
}
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
×
|
|
61
|
+
</button>
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
))}
|
|
65
|
+
</tbody>
|
|
66
|
+
<tfoot>
|
|
67
|
+
<tr>
|
|
68
|
+
<td>
|
|
69
|
+
<input type="checkbox" disabled />
|
|
70
|
+
</td>
|
|
71
|
+
<td colSpan={2}>
|
|
72
|
+
<form
|
|
73
|
+
onSubmit={async (event) => {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
const form = event.currentTarget;
|
|
76
|
+
const fieldset = form.querySelector("fieldset");
|
|
77
|
+
if (!(fieldset instanceof HTMLFieldSetElement)) return;
|
|
78
|
+
|
|
79
|
+
const formData = new FormData(form);
|
|
80
|
+
const desc = formData.get("description");
|
|
81
|
+
if (typeof desc !== "string") return;
|
|
82
|
+
|
|
83
|
+
fieldset.disabled = true;
|
|
84
|
+
try {
|
|
85
|
+
await addTask(desc);
|
|
86
|
+
form.reset();
|
|
87
|
+
} finally {
|
|
88
|
+
fieldset.disabled = false;
|
|
89
|
+
}
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<fieldset style={styleUnset}>
|
|
93
|
+
<input type="text" name="description" />{" "}
|
|
94
|
+
<button type="submit" title="Add task">
|
|
95
|
+
Add
|
|
96
|
+
</button>
|
|
97
|
+
</fieldset>
|
|
98
|
+
</form>
|
|
99
|
+
</td>
|
|
100
|
+
</tr>
|
|
101
|
+
</tfoot>
|
|
102
|
+
</table>
|
|
27
103
|
</>
|
|
28
104
|
);
|
|
29
105
|
};
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* for changes in the World state (using the System contracts).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { ClientComponents } from "./createClientComponents";
|
|
6
|
+
import { Hex } from "viem";
|
|
8
7
|
import { SetupNetworkResult } from "./setupNetwork";
|
|
9
|
-
import { singletonEntity } from "@latticexyz/store-sync/recs";
|
|
10
8
|
|
|
11
9
|
export type SystemCalls = ReturnType<typeof createSystemCalls>;
|
|
12
10
|
|
|
@@ -30,22 +28,27 @@ export function createSystemCalls(
|
|
|
30
28
|
* syncToRecs
|
|
31
29
|
* (https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L77-L83).
|
|
32
30
|
*/
|
|
33
|
-
{ worldContract, waitForTransaction }: SetupNetworkResult
|
|
34
|
-
{ Counter }: ClientComponents
|
|
31
|
+
{ tables, useStore, worldContract, waitForTransaction }: SetupNetworkResult
|
|
35
32
|
) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const tx = await worldContract.write.
|
|
33
|
+
const addTask = async (label: string) => {
|
|
34
|
+
const tx = await worldContract.write.addTask([label]);
|
|
35
|
+
await waitForTransaction(tx);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const toggleTask = async (key: Hex) => {
|
|
39
|
+
const isComplete = (useStore.getState().getValue(tables.Tasks, { key })?.completedAt ?? 0n) > 0n;
|
|
40
|
+
const tx = isComplete ? await worldContract.write.resetTask([key]) : await worldContract.write.completeTask([key]);
|
|
41
|
+
await waitForTransaction(tx);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const deleteTask = async (key: Hex) => {
|
|
45
|
+
const tx = await worldContract.write.deleteTask([key]);
|
|
44
46
|
await waitForTransaction(tx);
|
|
45
|
-
return getComponentValue(Counter, singletonEntity);
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
return {
|
|
49
|
-
|
|
50
|
+
addTask,
|
|
51
|
+
toggleTask,
|
|
52
|
+
deleteTask,
|
|
50
53
|
};
|
|
51
54
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* This file sets up all the definitions required for a MUD client.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { createClientComponents } from "./createClientComponents";
|
|
6
5
|
import { createSystemCalls } from "./createSystemCalls";
|
|
7
6
|
import { setupNetwork } from "./setupNetwork";
|
|
8
7
|
|
|
@@ -10,12 +9,10 @@ export type SetupResult = Awaited<ReturnType<typeof setup>>;
|
|
|
10
9
|
|
|
11
10
|
export async function setup() {
|
|
12
11
|
const network = await setupNetwork();
|
|
13
|
-
const
|
|
14
|
-
const systemCalls = createSystemCalls(network, components);
|
|
12
|
+
const systemCalls = createSystemCalls(network);
|
|
15
13
|
|
|
16
14
|
return {
|
|
17
15
|
network,
|
|
18
|
-
components,
|
|
19
16
|
systemCalls,
|
|
20
17
|
};
|
|
21
18
|
}
|
|
@@ -5,13 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, parseEther, ClientConfig } from "viem";
|
|
7
7
|
import { createFaucetService } from "@latticexyz/services/faucet";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { syncToZustand } from "@latticexyz/store-sync/zustand";
|
|
10
9
|
import { getNetworkConfig } from "./getNetworkConfig";
|
|
11
|
-
import { world } from "./world";
|
|
12
10
|
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
|
|
13
11
|
import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";
|
|
14
|
-
|
|
15
12
|
import { Subject, share } from "rxjs";
|
|
16
13
|
|
|
17
14
|
/*
|
|
@@ -74,8 +71,7 @@ export async function setupNetwork() {
|
|
|
74
71
|
* to the viem publicClient to make RPC calls to fetch MUD
|
|
75
72
|
* events from the chain.
|
|
76
73
|
*/
|
|
77
|
-
const {
|
|
78
|
-
world,
|
|
74
|
+
const { tables, useStore, latestBlock$, storedBlockLogs$, waitForTransaction } = await syncToZustand({
|
|
79
75
|
config: mudConfig,
|
|
80
76
|
address: networkConfig.worldAddress as Hex,
|
|
81
77
|
publicClient,
|
|
@@ -111,9 +107,8 @@ export async function setupNetwork() {
|
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
return {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
playerEntity: encodeEntity({ address: "address" }, { address: burnerWalletClient.account.address }),
|
|
110
|
+
tables,
|
|
111
|
+
useStore,
|
|
117
112
|
publicClient,
|
|
118
113
|
walletClient: burnerWalletClient,
|
|
119
114
|
latestBlock$,
|
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
# your deployment enviroment, but we're including this here for ease of local
|
|
5
5
|
# development. Please do not commit changes to this file!
|
|
6
6
|
#
|
|
7
|
+
# Enable debug logs for MUD CLI
|
|
8
|
+
DEBUG=mud:*
|
|
9
|
+
#
|
|
7
10
|
# Anvil default private key:
|
|
8
11
|
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
|
@@ -2,9 +2,12 @@ import { mudConfig } from "@latticexyz/world/register";
|
|
|
2
2
|
|
|
3
3
|
export default mudConfig({
|
|
4
4
|
tables: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Tasks: {
|
|
6
|
+
valueSchema: {
|
|
7
|
+
createdAt: "uint256",
|
|
8
|
+
completedAt: "uint256",
|
|
9
|
+
description: "string",
|
|
10
|
+
},
|
|
8
11
|
},
|
|
9
12
|
},
|
|
10
13
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
ds-test
|
|
2
|
-
forge-std
|
|
3
|
-
@latticexyz
|
|
1
|
+
ds-test/=node_modules/ds-test/src/
|
|
2
|
+
forge-std/=node_modules/forge-std/src/
|
|
3
|
+
@latticexyz/=node_modules/@latticexyz/
|
|
@@ -3,21 +3,30 @@ pragma solidity >=0.8.21;
|
|
|
3
3
|
|
|
4
4
|
import { Script } from "forge-std/Script.sol";
|
|
5
5
|
import { console } from "forge-std/console.sol";
|
|
6
|
+
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
|
|
7
|
+
|
|
6
8
|
import { IWorld } from "../src/codegen/world/IWorld.sol";
|
|
9
|
+
import { Tasks, TasksData } from "../src/codegen/index.sol";
|
|
7
10
|
|
|
8
11
|
contract PostDeploy is Script {
|
|
9
12
|
function run(address worldAddress) external {
|
|
13
|
+
// Specify a store so that you can use tables directly in PostDeploy
|
|
14
|
+
StoreSwitch.setStoreAddress(worldAddress);
|
|
15
|
+
|
|
10
16
|
// Load the private key from the `PRIVATE_KEY` environment variable (in .env)
|
|
11
17
|
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
|
|
12
18
|
|
|
13
19
|
// Start broadcasting transactions from the deployer account
|
|
14
20
|
vm.startBroadcast(deployerPrivateKey);
|
|
15
21
|
|
|
16
|
-
//
|
|
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).addTask("Take out the trash");
|
|
17
27
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.log("Increment via IWorld:", newValue);
|
|
28
|
+
bytes32 key = IWorld(worldAddress).addTask("Do the dishes");
|
|
29
|
+
IWorld(worldAddress).completeTask(key);
|
|
21
30
|
|
|
22
31
|
vm.stopBroadcast();
|
|
23
32
|
}
|