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
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-transaction-context-324984c5",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}}});
2
+ "use strict";var t=require("create-create-app"),s=require("path");var e={name:"create-mud",version:"2.0.0",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,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",
@@ -20,7 +20,7 @@
20
20
  "glob": "^8.0.3",
21
21
  "optimist": "^0.6.1",
22
22
  "ts-node": "^10.8.2",
23
- "typescript": "5.1.6",
23
+ "typescript": "5.4.2",
24
24
  "xml-js": "^1.6.11"
25
25
  }
26
26
  }
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@latticexyz/common": "{{mud-version}}",
15
15
  "@latticexyz/dev-tools": "{{mud-version}}",
16
- "@latticexyz/phaserx": "{{mud-version}}",
16
+ "@latticexyz/phaserx": "2.0.0-next.17",
17
17
  "@latticexyz/react": "{{mud-version}}",
18
18
  "@latticexyz/recs": "{{mud-version}}",
19
19
  "@latticexyz/schema-type": "{{mud-version}}",
@@ -29,7 +29,7 @@
29
29
  "simplex-noise": "^4.0.1",
30
30
  "styled-components": "^5.3.10",
31
31
  "use-resize-observer": "^9.1.0",
32
- "viem": "1.14.0",
32
+ "viem": "2.7.12",
33
33
  "zustand": "^4.3.8"
34
34
  },
35
35
  "devDependencies": {
@@ -37,7 +37,7 @@ export function createSystemCalls(
37
37
  * (https://github.com/latticexyz/mud/blob/main/templates/phaser/packages/client/src/mud/setupNetwork.ts#L75-L81).
38
38
  */
39
39
  { worldContract, waitForTransaction }: SetupNetworkResult,
40
- { Counter }: ClientComponents
40
+ { Counter }: ClientComponents,
41
41
  ) {
42
42
  const increment = async () => {
43
43
  /*
@@ -3,13 +3,24 @@
3
3
  * (https://viem.sh/docs/getting-started.html).
4
4
  * This line imports the functions we need from it.
5
5
  */
6
- import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, parseEther, ClientConfig } from "viem";
6
+ import {
7
+ createPublicClient,
8
+ fallback,
9
+ webSocket,
10
+ http,
11
+ createWalletClient,
12
+ Hex,
13
+ parseEther,
14
+ ClientConfig,
15
+ getContract,
16
+ } from "viem";
7
17
  import { createFaucetService } from "@latticexyz/services/faucet";
8
18
  import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
9
19
  import { getNetworkConfig } from "./getNetworkConfig";
10
20
  import { world } from "./world";
11
21
  import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
12
- import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";
22
+ import { createBurnerAccount, transportObserver, ContractWrite } from "@latticexyz/common";
23
+ import { transactionQueue, writeObserver } from "@latticexyz/common/actions";
13
24
  import { Subject, share } from "rxjs";
14
25
 
15
26
  /*
@@ -39,6 +50,12 @@ export async function setupNetwork() {
39
50
 
40
51
  const publicClient = createPublicClient(clientOptions);
41
52
 
53
+ /*
54
+ * Create an observable for contract writes that we can
55
+ * pass into MUD dev tools for transaction observability.
56
+ */
57
+ const write$ = new Subject<ContractWrite>();
58
+
42
59
  /*
43
60
  * Create a temporary wallet and a viem client for it
44
61
  * (see https://viem.sh/docs/clients/wallet.html).
@@ -47,13 +64,9 @@ export async function setupNetwork() {
47
64
  const burnerWalletClient = createWalletClient({
48
65
  ...clientOptions,
49
66
  account: burnerAccount,
50
- });
51
-
52
- /*
53
- * Create an observable for contract writes that we can
54
- * pass into MUD dev tools for transaction observability.
55
- */
56
- const write$ = new Subject<ContractWrite>();
67
+ })
68
+ .extend(transactionQueue())
69
+ .extend(writeObserver({ onWrite: (write) => write$.next(write) }));
57
70
 
58
71
  /*
59
72
  * Create an object for communicating with the deployed World.
@@ -61,9 +74,7 @@ export async function setupNetwork() {
61
74
  const worldContract = getContract({
62
75
  address: networkConfig.worldAddress as Hex,
63
76
  abi: IWorldAbi,
64
- publicClient,
65
- walletClient: burnerWalletClient,
66
- onWrite: (write) => write$.next(write),
77
+ client: { public: publicClient, wallet: burnerWalletClient },
67
78
  });
68
79
 
69
80
  /*
@@ -26,7 +26,7 @@ export const App = () => {
26
26
  worldAbi: networkLayer.network.worldContract.abi,
27
27
  write$: networkLayer.network.write$,
28
28
  recsWorld: networkLayer.world,
29
- })
29
+ }),
30
30
  );
31
31
  }
32
32
  }, [networkLayer]);
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
  import useResizeObserver, { ResizeHandler } from "use-resize-observer";
3
3
  import { throttle } from "lodash";
4
4
  import { createPhaserLayer } from "../../layers/phaser/createPhaserLayer";
@@ -80,7 +80,7 @@ export const usePhaserLayer = ({ networkLayer }: Props) => {
80
80
  }
81
81
  }
82
82
  },
83
- [container]
83
+ [container],
84
84
  );
85
85
 
86
86
  return useMemo(() => ({ ref, phaserLayer }), [ref, phaserLayer]);
@@ -1,10 +1,12 @@
1
- import { mudConfig } from "@latticexyz/world/register";
1
+ import { defineWorld } from "@latticexyz/world";
2
2
 
3
- export default mudConfig({
3
+ export default defineWorld({
4
4
  tables: {
5
5
  Counter: {
6
- keySchema: {},
7
- valueSchema: "uint32",
6
+ schema: {
7
+ value: "uint32",
8
+ },
9
+ key: [],
8
10
  },
9
11
  },
10
12
  });
@@ -25,8 +25,8 @@
25
25
  "@types/node": "^18.15.11",
26
26
  "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
27
27
  "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
28
- "prettier": "^2.6.2",
29
- "prettier-plugin-solidity": "1.1.3",
28
+ "prettier": "3.2.5",
29
+ "prettier-plugin-solidity": "1.3.1",
30
30
  "solhint": "^3.3.7",
31
31
  "solhint-config-mud": "{{mud-version}}",
32
32
  "solhint-plugin-mud": "{{mud-version}}"
@@ -3,4 +3,4 @@ pragma solidity >=0.8.24;
3
3
 
4
4
  /* Autogenerated file. Do not edit manually. */
5
5
 
6
- import { Counter, CounterTableId } from "./tables/Counter.sol";
6
+ import { Counter } from "./tables/Counter.sol";
@@ -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,48 +11,22 @@ 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: "Counter", typeId: RESOURCE_TABLE });`
23
- ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000436f756e746572000000000000000000);
24
- ResourceId constant CounterTableId = _tableId;
25
-
26
- FieldLayout constant _fieldLayout = FieldLayout.wrap(
27
- 0x0004010004000000000000000000000000000000000000000000000000000000
28
- );
29
-
30
19
  library Counter {
31
- /**
32
- * @notice Get the table values' field layout.
33
- * @return _fieldLayout The field layout for the table.
34
- */
35
- function getFieldLayout() internal pure returns (FieldLayout) {
36
- return _fieldLayout;
37
- }
38
-
39
- /**
40
- * @notice Get the table's key schema.
41
- * @return _keySchema The key schema for the table.
42
- */
43
- function getKeySchema() internal pure returns (Schema) {
44
- SchemaType[] memory _keySchema = new SchemaType[](0);
20
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Counter", typeId: RESOURCE_TABLE });`
21
+ ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000436f756e746572000000000000000000);
45
22
 
46
- return SchemaLib.encode(_keySchema);
47
- }
23
+ FieldLayout constant _fieldLayout =
24
+ FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000);
48
25
 
49
- /**
50
- * @notice Get the table's value schema.
51
- * @return _valueSchema The value schema for the table.
52
- */
53
- function getValueSchema() internal pure returns (Schema) {
54
- SchemaType[] memory _valueSchema = new SchemaType[](1);
55
- _valueSchema[0] = SchemaType.UINT32;
56
-
57
- return SchemaLib.encode(_valueSchema);
58
- }
26
+ // Hex-encoded key schema of ()
27
+ Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
28
+ // Hex-encoded value schema of (uint32)
29
+ Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000);
59
30
 
60
31
  /**
61
32
  * @notice Get the table's key field names.
@@ -78,14 +49,14 @@ library Counter {
78
49
  * @notice Register the table with its config.
79
50
  */
80
51
  function register() internal {
81
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
52
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
82
53
  }
83
54
 
84
55
  /**
85
56
  * @notice Register the table with its config.
86
57
  */
87
58
  function _register() internal {
88
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
59
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
89
60
  }
90
61
 
91
62
  /**
@@ -196,10 +167,10 @@ library Counter {
196
167
  * @return The lengths of the dynamic fields (packed into a single bytes32 value).
197
168
  * @return The dynamic (variable length) data, encoded into a sequence of bytes.
198
169
  */
199
- function encode(uint32 value) internal pure returns (bytes memory, PackedCounter, bytes memory) {
170
+ function encode(uint32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) {
200
171
  bytes memory _staticData = encodeStatic(value);
201
172
 
202
- PackedCounter _encodedLengths;
173
+ EncodedLengths _encodedLengths;
203
174
  bytes memory _dynamicData;
204
175
 
205
176
  return (_staticData, _encodedLengths, _dynamicData);
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
5
5
 
6
6
  /**
7
7
  * @title IIncrementSystem
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 IIncrementSystem {
@@ -9,10 +9,9 @@ import { IIncrementSystem } from "./IIncrementSystem.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, IIncrementSystem {
17
-
18
- }
17
+ interface IWorld is IBaseWorld, IIncrementSystem {}
@@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
6
6
  import { getKeysWithValue } from "@latticexyz/world-modules/src/modules/keyswithvalue/getKeysWithValue.sol";
7
7
 
8
8
  import { IWorld } from "../src/codegen/world/IWorld.sol";
9
- import { Counter, CounterTableId } from "../src/codegen/index.sol";
9
+ import { Counter } from "../src/codegen/index.sol";
10
10
 
11
11
  contract CounterTest is MudTest {
12
12
  function testWorldExists() public {
@@ -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",
@@ -23,7 +23,7 @@
23
23
  "react": "^18.2.0",
24
24
  "react-dom": "^18.2.0",
25
25
  "rxjs": "7.5.5",
26
- "viem": "1.14.0"
26
+ "viem": "2.7.12"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/react": "18.2.22",
@@ -31,7 +31,7 @@ export const App = () => {
31
31
 
32
32
  checkbox.disabled = true;
33
33
  try {
34
- await toggleTask(task.key.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.key);
54
+ await deleteTask(task.key.id);
55
55
  } finally {
56
56
  button.disabled = false;
57
57
  }
@@ -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
@@ -28,21 +28,21 @@ export function createSystemCalls(
28
28
  * syncToRecs
29
29
  * (https://github.com/latticexyz/mud/blob/main/templates/react/packages/client/src/mud/setupNetwork.ts#L77-L83).
30
30
  */
31
- { tables, useStore, worldContract, waitForTransaction }: SetupNetworkResult
31
+ { tables, useStore, worldContract, waitForTransaction }: SetupNetworkResult,
32
32
  ) {
33
33
  const addTask = async (label: string) => {
34
34
  const tx = await worldContract.write.addTask([label]);
35
35
  await waitForTransaction(tx);
36
36
  };
37
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]);
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 (key: Hex) => {
45
- const tx = await worldContract.write.deleteTask([key]);
44
+ const deleteTask = async (id: Hex) => {
45
+ const tx = await worldContract.write.deleteTask([id]);
46
46
  await waitForTransaction(tx);
47
47
  };
48
48
 
@@ -3,12 +3,23 @@
3
3
  * (https://viem.sh/docs/getting-started.html).
4
4
  * This line imports the functions we need from it.
5
5
  */
6
- import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, parseEther, ClientConfig } from "viem";
6
+ import {
7
+ createPublicClient,
8
+ fallback,
9
+ webSocket,
10
+ http,
11
+ createWalletClient,
12
+ Hex,
13
+ parseEther,
14
+ ClientConfig,
15
+ getContract,
16
+ } from "viem";
7
17
  import { createFaucetService } from "@latticexyz/services/faucet";
8
18
  import { syncToZustand } from "@latticexyz/store-sync/zustand";
9
19
  import { getNetworkConfig } from "./getNetworkConfig";
10
20
  import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
11
- import { createBurnerAccount, getContract, transportObserver, ContractWrite } from "@latticexyz/common";
21
+ import { createBurnerAccount, transportObserver, ContractWrite } from "@latticexyz/common";
22
+ import { transactionQueue, writeObserver } from "@latticexyz/common/actions";
12
23
  import { Subject, share } from "rxjs";
13
24
 
14
25
  /*
@@ -38,6 +49,12 @@ export async function setupNetwork() {
38
49
 
39
50
  const publicClient = createPublicClient(clientOptions);
40
51
 
52
+ /*
53
+ * Create an observable for contract writes that we can
54
+ * pass into MUD dev tools for transaction observability.
55
+ */
56
+ const write$ = new Subject<ContractWrite>();
57
+
41
58
  /*
42
59
  * Create a temporary wallet and a viem client for it
43
60
  * (see https://viem.sh/docs/clients/wallet.html).
@@ -46,13 +63,9 @@ export async function setupNetwork() {
46
63
  const burnerWalletClient = createWalletClient({
47
64
  ...clientOptions,
48
65
  account: burnerAccount,
49
- });
50
-
51
- /*
52
- * Create an observable for contract writes that we can
53
- * pass into MUD dev tools for transaction observability.
54
- */
55
- const write$ = new Subject<ContractWrite>();
66
+ })
67
+ .extend(transactionQueue())
68
+ .extend(writeObserver({ onWrite: (write) => write$.next(write) }));
56
69
 
57
70
  /*
58
71
  * Create an object for communicating with the deployed World.
@@ -60,9 +73,7 @@ export async function setupNetwork() {
60
73
  const worldContract = getContract({
61
74
  address: networkConfig.worldAddress as Hex,
62
75
  abi: IWorldAbi,
63
- publicClient,
64
- walletClient: burnerWalletClient,
65
- onWrite: (write) => write$.next(write),
76
+ client: { public: publicClient, wallet: burnerWalletClient },
66
77
  });
67
78
 
68
79
  /*
@@ -1,13 +1,15 @@
1
- import { mudConfig } from "@latticexyz/world/register";
1
+ import { defineWorld } from "@latticexyz/world";
2
2
 
3
- export default mudConfig({
3
+ export default defineWorld({
4
4
  tables: {
5
5
  Tasks: {
6
- valueSchema: {
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
  });
@@ -25,8 +25,8 @@
25
25
  "@types/node": "^18.15.11",
26
26
  "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
27
27
  "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
28
- "prettier": "^2.6.2",
29
- "prettier-plugin-solidity": "1.1.3",
28
+ "prettier": "3.2.5",
29
+ "prettier-plugin-solidity": "1.3.1",
30
30
  "solhint": "^3.3.7",
31
31
  "solhint-config-mud": "{{mud-version}}",
32
32
  "solhint-plugin-mud": "{{mud-version}}"
@@ -3,4 +3,4 @@ pragma solidity >=0.8.24;
3
3
 
4
4
  /* Autogenerated file. Do not edit manually. */
5
5
 
6
- import { Tasks, TasksData, TasksTableId } from "./tables/Tasks.sol";
6
+ import { Tasks, TasksData } from "./tables/Tasks.sol";