Skip to content

Commit d5f4e1e

Browse files
authored
feat(create-mud): new react template with stash/entrykit (#3478)
1 parent e45e375 commit d5f4e1e

54 files changed

Lines changed: 3112 additions & 1088 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/cuddly-pugs-cough.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/entrykit": patch
3+
---
4+
5+
Bumped react-error-boundary dependency.

.changeset/five-bats-live.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-mud": patch
3+
---
4+
5+
Updated React template with Stash client state library, EntryKit for wallet support, and a cleaned up app structure.

packages/create-mud/scripts/copy-templates.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const __dirname = path.dirname(__filename);
1212
const packageDir = path.resolve(__dirname, "..");
1313
const rootDir = path.resolve(packageDir, "../..");
1414

15+
// TODO: could swap this with `pnpm m ls --json --depth=-1`
1516
const mudPackageNames = await (async () => {
1617
const files = await glob("packages/*/package.json", { cwd: rootDir });
1718
const packages = await Promise.all(
@@ -36,16 +37,17 @@ const __dirname = path.dirname(__filename);
3637

3738
await fs.mkdir(path.dirname(destPath), { recursive: true });
3839

39-
// Replace all MUD package links with mustache placeholder used by create-create-app
40-
// that will be replaced with the latest MUD version number when the template is used.
4140
if (/package\.json$/.test(destPath)) {
42-
const source = await fs.readFile(sourcePath, "utf-8");
43-
await fs.writeFile(
44-
destPath,
45-
source.replace(/"([^"]+)":\s*"(link|file):[^"]+"/g, (match, packageName) =>
46-
mudPackageNames.includes(packageName) ? `"${packageName}": "{{mud-version}}"` : match,
47-
),
41+
let source = await fs.readFile(sourcePath, "utf-8");
42+
// Replace all MUD package links with mustache placeholder used by create-create-app
43+
// that will be replaced with the latest MUD version number when the template is used.
44+
source = source.replace(/"([^"]+)":\s*"(link|file):[^"]+"/g, (match, packageName) =>
45+
mudPackageNames.includes(packageName) ? `"${packageName}": "{{mud-version}}"` : match,
4846
);
47+
const json = JSON.parse(source);
48+
// Strip out pnpm overrides
49+
delete json.pnpm;
50+
await fs.writeFile(destPath, JSON.stringify(json, null, 2) + "\n");
4951
}
5052
// Replace template workspace root `tsconfig.json` files (which have paths relative to monorepo)
5153
// with one that inherits our base tsconfig.

packages/entrykit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"debug": "^4.3.4",
5757
"dotenv": "^16.0.3",
5858
"permissionless": "0.2.25",
59-
"react-error-boundary": "^4.0.13",
59+
"react-error-boundary": "5.0.0",
6060
"react-merge-refs": "^2.1.1",
6161
"tailwind-merge": "^1.12.0",
6262
"usehooks-ts": "^3.1.0",

pnpm-lock.yaml

Lines changed: 6 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/react/.gitignore

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
.DS_Store
2+
logs
3+
*.log
4+
15
node_modules
26

3-
# mud artifacts
4-
.mud
5-
# sqlite indexer data
6-
*.db
7-
*.db-journal
7+
.env.*
8+
9+
# foundry
10+
cache
11+
broadcast
12+
out/*
13+
!out/IWorld.sol
14+
out/IWorld.sol/*
15+
!out/IWorld.sol/IWorld.abi.json
16+
!out/IWorld.sol/IWorld.abi.d.json.ts

templates/react/mprocs.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
scrollback: 10000
12
procs:
23
client:
34
cwd: packages/client
45
shell: pnpm run dev
56
contracts:
67
cwd: packages/contracts
78
shell: pnpm mud dev-contracts --rpc http://127.0.0.1:8545
9+
deploy-prereqs:
10+
cwd: packages/contracts
11+
shell: pnpm deploy-local-prereqs
12+
env:
13+
DEBUG: "mud:*"
14+
# Anvil default account (0x70997970C51812dc3A010C7d01b50e0d17dc79C8)
15+
PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
816
anvil:
917
cwd: packages/contracts
10-
shell: anvil --base-fee 0 --block-time 2
18+
shell: anvil --block-time 2
1119
explorer:
1220
cwd: packages/contracts
1321
shell: pnpm explorer

templates/react/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,12 @@
2727
"engines": {
2828
"node": "^18",
2929
"pnpm": "^8 || ^9"
30+
},
31+
"pnpm": {
32+
"overrides": {
33+
"@tanstack/react-query": "link:../../packages/entrykit/node_modules/@tanstack/react-query",
34+
"@types/react": "link:../../packages/entrykit/node_modules/@types/react",
35+
"wagmi": "link:../../packages/entrykit/node_modules/wagmi"
36+
}
3037
}
3138
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
node_modules
21
dist
3-
.DS_Store

templates/react/packages/client/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>a minimal MUD client</title>
6+
<title>a MUD app</title>
77
</head>
88
<body>
99
<div id="react-root"></div>

0 commit comments

Comments
 (0)