Skip to content

Commit

Permalink
chore: add example for multiple namespaces (latticexyz#2891)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaaa authored Jun 5, 2024
1 parent 22c9db7 commit 8987984
Show file tree
Hide file tree
Showing 23 changed files with 1,588 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
example: [minimal]
example: [minimal, multiple-namespaces]

steps:
- name: Checkout
Expand Down
11 changes: 11 additions & 0 deletions examples/multiple-namespaces/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This .env file is for demonstration purposes only.
#
# This should usually be excluded via .gitignore and the env vars attached to
# your deployment enviroment, but we're including this here for ease of local
# development. Please do not commit changes to this file!
#
# Anvil default private key:
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
FAUCET_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
RPC_HTTP_URL=http://127.0.0.1:8545
DEBUG=mud:*
9 changes: 9 additions & 0 deletions examples/multiple-namespaces/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
out/
cache/
node_modules/
bindings/
artifacts/
broadcast/

# Ignore MUD deploy artifacts
deploys/**/*.json
12 changes: 12 additions & 0 deletions examples/multiple-namespaces/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["solhint:recommended", "mud"],
"plugins": ["mud"],
"rules": {
"compiler-version": ["error", ">=0.8.0"],
"avoid-low-level-calls": "off",
"no-inline-assembly": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"no-empty-blocks": "off",
"no-complex-fallback": "off"
}
}
21 changes: 21 additions & 0 deletions examples/multiple-namespaces/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[profile.default]
solc = "0.8.24"
ffi = false
fuzz_runs = 256
optimizer = true
optimizer_runs = 3000
verbosity = 2
src = "src"
test = "test"
out = "out"
allow_paths = [
# pnpm symlinks to the project root's node_modules
"../../node_modules",
# we're also using linked mud packages from the monorepo
"../../../../packages"
]
extra_output_files = [
"abi",
"evm.bytecode"
]
fs_permissions = [{ access = "read", path = "./"}]
23 changes: 23 additions & 0 deletions examples/multiple-namespaces/mud.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineWorld } from "@latticexyz/world";

export default defineWorld({
namespace: "game",
codegen: { namespaceDirectories: true },
tables: {
Health: {
schema: {
player: "address",
value: "uint32",
},
key: ["player"],
},
Position: {
schema: {
player: "address",
x: "int32",
y: "int32",
},
key: ["player"],
},
},
});
35 changes: 35 additions & 0 deletions examples/multiple-namespaces/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "mud-example-multiple-namespaces",
"private": true,
"scripts": {
"build": "mud build",
"clean": "forge clean && rimraf src/codegen",
"deploy:local": "mud deploy",
"dev": "mud dev-contracts",
"faucet": "DEBUG=mud:faucet faucet-server",
"lint": "pnpm run prettier && pnpm run solhint",
"prettier": "prettier --write 'src/**/*.sol'",
"solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix",
"test": "mud test"
},
"devDependencies": {
"@latticexyz/cli": "link:../../packages/cli",
"@latticexyz/faucet": "link:../../packages/faucet",
"@latticexyz/schema-type": "link:../../packages/schema-type",
"@latticexyz/store": "link:../../packages/store",
"@latticexyz/world": "link:../../packages/world",
"@latticexyz/world-modules": "link:../../packages/world-modules",
"@solidstate/contracts": "^0.0.52",
"@types/node": "^18.15.11",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
"prettier": "3.2.5",
"prettier-plugin-solidity": "1.3.1",
"rimraf": "^3.0.2",
"solhint": "^3.4.1",
"solhint-config-mud": "file:../../packages/solhint-config-mud",
"solhint-plugin-mud": "file:../../packages/solhint-plugin-mud",
"ts-node": "^10.9.1",
"typescript": "5.4.2"
}
}
Loading

0 comments on commit 8987984

Please sign in to comment.