create-mud 2.0.0-next.2 → 2.0.0-next.3

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 CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var t=require("create-create-app"),a=require("path");var e={name:"create-mud",version:"2.0.0-next.2",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:phaser && pnpm run test:threejs","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: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 i=(0,a.resolve)(__dirname,"..","dist","templates");(0,t.create)("create-mud",{templateRoot:i,defaultTemplate:"vanilla",defaultPackageManager:"pnpm",promptForDescription:!1,promptForAuthor:!1,promptForEmail:!1,promptForLicense:!1,promptForTemplate:!0,caveat:({answers:r,packageManager:s})=>`Done! Play in the MUD with \`cd ${r.name}\` and \`${s} 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"),a=require("path");var e={name:"create-mud",version:"2.0.0-next.3",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:phaser && pnpm run test:threejs","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: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 i=(0,a.resolve)(__dirname,"..","dist","templates");(0,t.create)("create-mud",{templateRoot:i,defaultTemplate:"vanilla",defaultPackageManager:"pnpm",promptForDescription:!1,promptForAuthor:!1,promptForEmail:!1,promptForLicense:!1,promptForTemplate:!0,caveat:({answers:r,packageManager:s})=>`Done! Play in the MUD with \`cd ${r.name}\` and \`${s} run dev\``,extra:{"mud-version":{type:"input",describe:"The version of MUD packages to use, defaults to latest",default:e.version}}});
@@ -14,12 +14,11 @@
14
14
  "@ethersproject/providers": "^5.7.2",
15
15
  "@latticexyz/common": "{{mud-version}}",
16
16
  "@latticexyz/dev-tools": "{{mud-version}}",
17
- "@latticexyz/network": "{{mud-version}}",
18
17
  "@latticexyz/phaserx": "{{mud-version}}",
19
18
  "@latticexyz/react": "{{mud-version}}",
20
19
  "@latticexyz/recs": "{{mud-version}}",
21
20
  "@latticexyz/schema-type": "{{mud-version}}",
22
- "@latticexyz/std-client": "{{mud-version}}",
21
+ "@latticexyz/services": "{{mud-version}}",
23
22
  "@latticexyz/store-sync": "{{mud-version}}",
24
23
  "@latticexyz/utils": "{{mud-version}}",
25
24
  "@latticexyz/world": "{{mud-version}}",
@@ -1,4 +1,4 @@
1
- import { getBurnerWallet } from "@latticexyz/std-client";
1
+ import { getBurnerPrivateKey } from "@latticexyz/common";
2
2
  import worldsJson from "contracts/worlds.json";
3
3
  import { supportedChains } from "./supportedChains";
4
4
 
@@ -24,7 +24,7 @@ export async function getNetworkConfig() {
24
24
  : world?.blockNumber ?? 0n;
25
25
 
26
26
  return {
27
- privateKey: getBurnerWallet().value,
27
+ privateKey: getBurnerPrivateKey(),
28
28
  chainId,
29
29
  chain,
30
30
  faucetServiceUrl: params.get("faucet") ?? chain.faucetUrl,
@@ -1,5 +1,5 @@
1
1
  import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, parseEther, ClientConfig } from "viem";
2
- import { createFaucetService } from "@latticexyz/network";
2
+ import { createFaucetService } from "@latticexyz/services/faucet";
3
3
  import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
4
4
  import { getNetworkConfig } from "./getNetworkConfig";
5
5
  import { world } from "./world";
@@ -21,54 +21,47 @@ bytes32 constant _tableId = bytes32(abi.encodePacked(bytes16(""), bytes16("Count
21
21
  bytes32 constant CounterTableId = _tableId;
22
22
 
23
23
  library Counter {
24
- /** Get the table's schema */
25
- function getSchema() internal pure returns (Schema) {
26
- SchemaType[] memory _schema = new SchemaType[](1);
27
- _schema[0] = SchemaType.UINT32;
28
-
29
- return SchemaLib.encode(_schema);
30
- }
31
-
24
+ /** Get the table's key schema */
32
25
  function getKeySchema() internal pure returns (Schema) {
33
26
  SchemaType[] memory _schema = new SchemaType[](0);
34
27
 
35
28
  return SchemaLib.encode(_schema);
36
29
  }
37
30
 
38
- /** Get the table's metadata */
39
- function getMetadata() internal pure returns (string memory, string[] memory) {
40
- string[] memory _fieldNames = new string[](1);
41
- _fieldNames[0] = "value";
42
- return ("Counter", _fieldNames);
31
+ /** Get the table's value schema */
32
+ function getValueSchema() internal pure returns (Schema) {
33
+ SchemaType[] memory _schema = new SchemaType[](1);
34
+ _schema[0] = SchemaType.UINT32;
35
+
36
+ return SchemaLib.encode(_schema);
43
37
  }
44
38
 
45
- /** Register the table's schema */
46
- function registerSchema() internal {
47
- StoreSwitch.registerSchema(_tableId, getSchema(), getKeySchema());
39
+ /** Get the table's key names */
40
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
41
+ keyNames = new string[](0);
48
42
  }
49
43
 
50
- /** Register the table's schema (using the specified store) */
51
- function registerSchema(IStore _store) internal {
52
- _store.registerSchema(_tableId, getSchema(), getKeySchema());
44
+ /** Get the table's field names */
45
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
46
+ fieldNames = new string[](1);
47
+ fieldNames[0] = "value";
53
48
  }
54
49
 
55
- /** Set the table's metadata */
56
- function setMetadata() internal {
57
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
58
- StoreSwitch.setMetadata(_tableId, _tableName, _fieldNames);
50
+ /** Register the table's key schema, value schema, key names and value names */
51
+ function register() internal {
52
+ StoreSwitch.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
59
53
  }
60
54
 
61
- /** Set the table's metadata (using the specified store) */
62
- function setMetadata(IStore _store) internal {
63
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
64
- _store.setMetadata(_tableId, _tableName, _fieldNames);
55
+ /** Register the table's key schema, value schema, key names and value names (using the specified store) */
56
+ function register(IStore _store) internal {
57
+ _store.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
65
58
  }
66
59
 
67
60
  /** Get value */
68
61
  function get() internal view returns (uint32 value) {
69
62
  bytes32[] memory _keyTuple = new bytes32[](0);
70
63
 
71
- bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0);
64
+ bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getValueSchema());
72
65
  return (uint32(Bytes.slice4(_blob, 0)));
73
66
  }
74
67
 
@@ -76,7 +69,7 @@ library Counter {
76
69
  function get(IStore _store) internal view returns (uint32 value) {
77
70
  bytes32[] memory _keyTuple = new bytes32[](0);
78
71
 
79
- bytes memory _blob = _store.getField(_tableId, _keyTuple, 0);
72
+ bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getValueSchema());
80
73
  return (uint32(Bytes.slice4(_blob, 0)));
81
74
  }
82
75
 
@@ -84,14 +77,14 @@ library Counter {
84
77
  function set(uint32 value) internal {
85
78
  bytes32[] memory _keyTuple = new bytes32[](0);
86
79
 
87
- StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)));
80
+ StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getValueSchema());
88
81
  }
89
82
 
90
83
  /** Set value (using the specified store) */
91
84
  function set(IStore _store, uint32 value) internal {
92
85
  bytes32[] memory _keyTuple = new bytes32[](0);
93
86
 
94
- _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)));
87
+ _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getValueSchema());
95
88
  }
96
89
 
97
90
  /** Tightly pack full data using this table's schema */
@@ -100,21 +93,23 @@ library Counter {
100
93
  }
101
94
 
102
95
  /** Encode keys as a bytes32 array using this table's schema */
103
- function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) {
104
- _keyTuple = new bytes32[](0);
96
+ function encodeKeyTuple() internal pure returns (bytes32[] memory) {
97
+ bytes32[] memory _keyTuple = new bytes32[](0);
98
+
99
+ return _keyTuple;
105
100
  }
106
101
 
107
102
  /* Delete all data for given keys */
108
103
  function deleteRecord() internal {
109
104
  bytes32[] memory _keyTuple = new bytes32[](0);
110
105
 
111
- StoreSwitch.deleteRecord(_tableId, _keyTuple);
106
+ StoreSwitch.deleteRecord(_tableId, _keyTuple, getValueSchema());
112
107
  }
113
108
 
114
109
  /* Delete all data for given keys (using the specified store) */
115
110
  function deleteRecord(IStore _store) internal {
116
111
  bytes32[] memory _keyTuple = new bytes32[](0);
117
112
 
118
- _store.deleteRecord(_tableId, _keyTuple);
113
+ _store.deleteRecord(_tableId, _keyTuple, getValueSchema());
119
114
  }
120
115
  }
@@ -14,11 +14,10 @@
14
14
  "@ethersproject/providers": "^5.7.2",
15
15
  "@latticexyz/common": "{{mud-version}}",
16
16
  "@latticexyz/dev-tools": "{{mud-version}}",
17
- "@latticexyz/network": "{{mud-version}}",
18
17
  "@latticexyz/react": "{{mud-version}}",
19
18
  "@latticexyz/recs": "{{mud-version}}",
20
19
  "@latticexyz/schema-type": "{{mud-version}}",
21
- "@latticexyz/std-client": "{{mud-version}}",
20
+ "@latticexyz/services": "{{mud-version}}",
22
21
  "@latticexyz/store-sync": "{{mud-version}}",
23
22
  "@latticexyz/utils": "{{mud-version}}",
24
23
  "@latticexyz/world": "{{mud-version}}",
@@ -1,4 +1,4 @@
1
- import { getBurnerWallet } from "@latticexyz/std-client";
1
+ import { getBurnerPrivateKey } from "@latticexyz/common";
2
2
  import worldsJson from "contracts/worlds.json";
3
3
  import { supportedChains } from "./supportedChains";
4
4
 
@@ -24,7 +24,7 @@ export async function getNetworkConfig() {
24
24
  : world?.blockNumber ?? 0n;
25
25
 
26
26
  return {
27
- privateKey: getBurnerWallet().value,
27
+ privateKey: getBurnerPrivateKey(),
28
28
  chainId,
29
29
  chain,
30
30
  faucetServiceUrl: params.get("faucet") ?? chain.faucetUrl,
@@ -1,5 +1,5 @@
1
1
  import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, parseEther, ClientConfig } from "viem";
2
- import { createFaucetService } from "@latticexyz/network";
2
+ import { createFaucetService } from "@latticexyz/services/faucet";
3
3
  import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
4
4
  import { getNetworkConfig } from "./getNetworkConfig";
5
5
  import { world } from "./world";
@@ -21,54 +21,47 @@ bytes32 constant _tableId = bytes32(abi.encodePacked(bytes16(""), bytes16("Count
21
21
  bytes32 constant CounterTableId = _tableId;
22
22
 
23
23
  library Counter {
24
- /** Get the table's schema */
25
- function getSchema() internal pure returns (Schema) {
26
- SchemaType[] memory _schema = new SchemaType[](1);
27
- _schema[0] = SchemaType.UINT32;
28
-
29
- return SchemaLib.encode(_schema);
30
- }
31
-
24
+ /** Get the table's key schema */
32
25
  function getKeySchema() internal pure returns (Schema) {
33
26
  SchemaType[] memory _schema = new SchemaType[](0);
34
27
 
35
28
  return SchemaLib.encode(_schema);
36
29
  }
37
30
 
38
- /** Get the table's metadata */
39
- function getMetadata() internal pure returns (string memory, string[] memory) {
40
- string[] memory _fieldNames = new string[](1);
41
- _fieldNames[0] = "value";
42
- return ("Counter", _fieldNames);
31
+ /** Get the table's value schema */
32
+ function getValueSchema() internal pure returns (Schema) {
33
+ SchemaType[] memory _schema = new SchemaType[](1);
34
+ _schema[0] = SchemaType.UINT32;
35
+
36
+ return SchemaLib.encode(_schema);
43
37
  }
44
38
 
45
- /** Register the table's schema */
46
- function registerSchema() internal {
47
- StoreSwitch.registerSchema(_tableId, getSchema(), getKeySchema());
39
+ /** Get the table's key names */
40
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
41
+ keyNames = new string[](0);
48
42
  }
49
43
 
50
- /** Register the table's schema (using the specified store) */
51
- function registerSchema(IStore _store) internal {
52
- _store.registerSchema(_tableId, getSchema(), getKeySchema());
44
+ /** Get the table's field names */
45
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
46
+ fieldNames = new string[](1);
47
+ fieldNames[0] = "value";
53
48
  }
54
49
 
55
- /** Set the table's metadata */
56
- function setMetadata() internal {
57
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
58
- StoreSwitch.setMetadata(_tableId, _tableName, _fieldNames);
50
+ /** Register the table's key schema, value schema, key names and value names */
51
+ function register() internal {
52
+ StoreSwitch.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
59
53
  }
60
54
 
61
- /** Set the table's metadata (using the specified store) */
62
- function setMetadata(IStore _store) internal {
63
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
64
- _store.setMetadata(_tableId, _tableName, _fieldNames);
55
+ /** Register the table's key schema, value schema, key names and value names (using the specified store) */
56
+ function register(IStore _store) internal {
57
+ _store.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
65
58
  }
66
59
 
67
60
  /** Get value */
68
61
  function get() internal view returns (uint32 value) {
69
62
  bytes32[] memory _keyTuple = new bytes32[](0);
70
63
 
71
- bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0);
64
+ bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getValueSchema());
72
65
  return (uint32(Bytes.slice4(_blob, 0)));
73
66
  }
74
67
 
@@ -76,7 +69,7 @@ library Counter {
76
69
  function get(IStore _store) internal view returns (uint32 value) {
77
70
  bytes32[] memory _keyTuple = new bytes32[](0);
78
71
 
79
- bytes memory _blob = _store.getField(_tableId, _keyTuple, 0);
72
+ bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getValueSchema());
80
73
  return (uint32(Bytes.slice4(_blob, 0)));
81
74
  }
82
75
 
@@ -84,14 +77,14 @@ library Counter {
84
77
  function set(uint32 value) internal {
85
78
  bytes32[] memory _keyTuple = new bytes32[](0);
86
79
 
87
- StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)));
80
+ StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getValueSchema());
88
81
  }
89
82
 
90
83
  /** Set value (using the specified store) */
91
84
  function set(IStore _store, uint32 value) internal {
92
85
  bytes32[] memory _keyTuple = new bytes32[](0);
93
86
 
94
- _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)));
87
+ _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getValueSchema());
95
88
  }
96
89
 
97
90
  /** Tightly pack full data using this table's schema */
@@ -100,21 +93,23 @@ library Counter {
100
93
  }
101
94
 
102
95
  /** Encode keys as a bytes32 array using this table's schema */
103
- function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) {
104
- _keyTuple = new bytes32[](0);
96
+ function encodeKeyTuple() internal pure returns (bytes32[] memory) {
97
+ bytes32[] memory _keyTuple = new bytes32[](0);
98
+
99
+ return _keyTuple;
105
100
  }
106
101
 
107
102
  /* Delete all data for given keys */
108
103
  function deleteRecord() internal {
109
104
  bytes32[] memory _keyTuple = new bytes32[](0);
110
105
 
111
- StoreSwitch.deleteRecord(_tableId, _keyTuple);
106
+ StoreSwitch.deleteRecord(_tableId, _keyTuple, getValueSchema());
112
107
  }
113
108
 
114
109
  /* Delete all data for given keys (using the specified store) */
115
110
  function deleteRecord(IStore _store) internal {
116
111
  bytes32[] memory _keyTuple = new bytes32[](0);
117
112
 
118
- _store.deleteRecord(_tableId, _keyTuple);
113
+ _store.deleteRecord(_tableId, _keyTuple, getValueSchema());
119
114
  }
120
115
  }
@@ -14,11 +14,10 @@
14
14
  "@ethersproject/providers": "^5.7.2",
15
15
  "@latticexyz/common": "{{mud-version}}",
16
16
  "@latticexyz/dev-tools": "{{mud-version}}",
17
- "@latticexyz/network": "{{mud-version}}",
18
17
  "@latticexyz/react": "{{mud-version}}",
19
18
  "@latticexyz/recs": "{{mud-version}}",
20
19
  "@latticexyz/schema-type": "{{mud-version}}",
21
- "@latticexyz/std-client": "{{mud-version}}",
20
+ "@latticexyz/services": "{{mud-version}}",
22
21
  "@latticexyz/store-sync": "{{mud-version}}",
23
22
  "@latticexyz/utils": "{{mud-version}}",
24
23
  "@latticexyz/world": "{{mud-version}}",
@@ -1,4 +1,4 @@
1
- import { getBurnerWallet } from "@latticexyz/std-client";
1
+ import { getBurnerPrivateKey } from "@latticexyz/common";
2
2
  import worldsJson from "contracts/worlds.json";
3
3
  import { supportedChains } from "./supportedChains";
4
4
 
@@ -24,7 +24,7 @@ export async function getNetworkConfig() {
24
24
  : world?.blockNumber ?? 0n;
25
25
 
26
26
  return {
27
- privateKey: getBurnerWallet().value,
27
+ privateKey: getBurnerPrivateKey(),
28
28
  chainId,
29
29
  chain,
30
30
  faucetServiceUrl: params.get("faucet") ?? chain.faucetUrl,
@@ -1,5 +1,5 @@
1
1
  import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, parseEther, ClientConfig } from "viem";
2
- import { createFaucetService } from "@latticexyz/network";
2
+ import { createFaucetService } from "@latticexyz/services/faucet";
3
3
  import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
4
4
  import { getNetworkConfig } from "./getNetworkConfig";
5
5
  import { world } from "./world";
@@ -27,16 +27,7 @@ struct PositionData {
27
27
  }
28
28
 
29
29
  library Position {
30
- /** Get the table's schema */
31
- function getSchema() internal pure returns (Schema) {
32
- SchemaType[] memory _schema = new SchemaType[](3);
33
- _schema[0] = SchemaType.INT32;
34
- _schema[1] = SchemaType.INT32;
35
- _schema[2] = SchemaType.INT32;
36
-
37
- return SchemaLib.encode(_schema);
38
- }
39
-
30
+ /** Get the table's key schema */
40
31
  function getKeySchema() internal pure returns (Schema) {
41
32
  SchemaType[] memory _schema = new SchemaType[](1);
42
33
  _schema[0] = SchemaType.BYTES32;
@@ -44,35 +35,38 @@ library Position {
44
35
  return SchemaLib.encode(_schema);
45
36
  }
46
37
 
47
- /** Get the table's metadata */
48
- function getMetadata() internal pure returns (string memory, string[] memory) {
49
- string[] memory _fieldNames = new string[](3);
50
- _fieldNames[0] = "x";
51
- _fieldNames[1] = "y";
52
- _fieldNames[2] = "z";
53
- return ("Position", _fieldNames);
38
+ /** Get the table's value schema */
39
+ function getValueSchema() internal pure returns (Schema) {
40
+ SchemaType[] memory _schema = new SchemaType[](3);
41
+ _schema[0] = SchemaType.INT32;
42
+ _schema[1] = SchemaType.INT32;
43
+ _schema[2] = SchemaType.INT32;
44
+
45
+ return SchemaLib.encode(_schema);
54
46
  }
55
47
 
56
- /** Register the table's schema */
57
- function registerSchema() internal {
58
- StoreSwitch.registerSchema(_tableId, getSchema(), getKeySchema());
48
+ /** Get the table's key names */
49
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
50
+ keyNames = new string[](1);
51
+ keyNames[0] = "key";
59
52
  }
60
53
 
61
- /** Register the table's schema (using the specified store) */
62
- function registerSchema(IStore _store) internal {
63
- _store.registerSchema(_tableId, getSchema(), getKeySchema());
54
+ /** Get the table's field names */
55
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
56
+ fieldNames = new string[](3);
57
+ fieldNames[0] = "x";
58
+ fieldNames[1] = "y";
59
+ fieldNames[2] = "z";
64
60
  }
65
61
 
66
- /** Set the table's metadata */
67
- function setMetadata() internal {
68
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
69
- StoreSwitch.setMetadata(_tableId, _tableName, _fieldNames);
62
+ /** Register the table's key schema, value schema, key names and value names */
63
+ function register() internal {
64
+ StoreSwitch.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
70
65
  }
71
66
 
72
- /** Set the table's metadata (using the specified store) */
73
- function setMetadata(IStore _store) internal {
74
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
75
- _store.setMetadata(_tableId, _tableName, _fieldNames);
67
+ /** Register the table's key schema, value schema, key names and value names (using the specified store) */
68
+ function register(IStore _store) internal {
69
+ _store.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
76
70
  }
77
71
 
78
72
  /** Get x */
@@ -80,7 +74,7 @@ library Position {
80
74
  bytes32[] memory _keyTuple = new bytes32[](1);
81
75
  _keyTuple[0] = key;
82
76
 
83
- bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0);
77
+ bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getValueSchema());
84
78
  return (int32(uint32(Bytes.slice4(_blob, 0))));
85
79
  }
86
80
 
@@ -89,7 +83,7 @@ library Position {
89
83
  bytes32[] memory _keyTuple = new bytes32[](1);
90
84
  _keyTuple[0] = key;
91
85
 
92
- bytes memory _blob = _store.getField(_tableId, _keyTuple, 0);
86
+ bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getValueSchema());
93
87
  return (int32(uint32(Bytes.slice4(_blob, 0))));
94
88
  }
95
89
 
@@ -98,7 +92,7 @@ library Position {
98
92
  bytes32[] memory _keyTuple = new bytes32[](1);
99
93
  _keyTuple[0] = key;
100
94
 
101
- StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)));
95
+ StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getValueSchema());
102
96
  }
103
97
 
104
98
  /** Set x (using the specified store) */
@@ -106,7 +100,7 @@ library Position {
106
100
  bytes32[] memory _keyTuple = new bytes32[](1);
107
101
  _keyTuple[0] = key;
108
102
 
109
- _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)));
103
+ _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getValueSchema());
110
104
  }
111
105
 
112
106
  /** Get y */
@@ -114,7 +108,7 @@ library Position {
114
108
  bytes32[] memory _keyTuple = new bytes32[](1);
115
109
  _keyTuple[0] = key;
116
110
 
117
- bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1);
111
+ bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getValueSchema());
118
112
  return (int32(uint32(Bytes.slice4(_blob, 0))));
119
113
  }
120
114
 
@@ -123,7 +117,7 @@ library Position {
123
117
  bytes32[] memory _keyTuple = new bytes32[](1);
124
118
  _keyTuple[0] = key;
125
119
 
126
- bytes memory _blob = _store.getField(_tableId, _keyTuple, 1);
120
+ bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getValueSchema());
127
121
  return (int32(uint32(Bytes.slice4(_blob, 0))));
128
122
  }
129
123
 
@@ -132,7 +126,7 @@ library Position {
132
126
  bytes32[] memory _keyTuple = new bytes32[](1);
133
127
  _keyTuple[0] = key;
134
128
 
135
- StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)));
129
+ StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getValueSchema());
136
130
  }
137
131
 
138
132
  /** Set y (using the specified store) */
@@ -140,7 +134,7 @@ library Position {
140
134
  bytes32[] memory _keyTuple = new bytes32[](1);
141
135
  _keyTuple[0] = key;
142
136
 
143
- _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)));
137
+ _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getValueSchema());
144
138
  }
145
139
 
146
140
  /** Get z */
@@ -148,7 +142,7 @@ library Position {
148
142
  bytes32[] memory _keyTuple = new bytes32[](1);
149
143
  _keyTuple[0] = key;
150
144
 
151
- bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2);
145
+ bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getValueSchema());
152
146
  return (int32(uint32(Bytes.slice4(_blob, 0))));
153
147
  }
154
148
 
@@ -157,7 +151,7 @@ library Position {
157
151
  bytes32[] memory _keyTuple = new bytes32[](1);
158
152
  _keyTuple[0] = key;
159
153
 
160
- bytes memory _blob = _store.getField(_tableId, _keyTuple, 2);
154
+ bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getValueSchema());
161
155
  return (int32(uint32(Bytes.slice4(_blob, 0))));
162
156
  }
163
157
 
@@ -166,7 +160,7 @@ library Position {
166
160
  bytes32[] memory _keyTuple = new bytes32[](1);
167
161
  _keyTuple[0] = key;
168
162
 
169
- StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)));
163
+ StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)), getValueSchema());
170
164
  }
171
165
 
172
166
  /** Set z (using the specified store) */
@@ -174,7 +168,7 @@ library Position {
174
168
  bytes32[] memory _keyTuple = new bytes32[](1);
175
169
  _keyTuple[0] = key;
176
170
 
177
- _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)));
171
+ _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)), getValueSchema());
178
172
  }
179
173
 
180
174
  /** Get the full data */
@@ -182,7 +176,7 @@ library Position {
182
176
  bytes32[] memory _keyTuple = new bytes32[](1);
183
177
  _keyTuple[0] = key;
184
178
 
185
- bytes memory _blob = StoreSwitch.getRecord(_tableId, _keyTuple, getSchema());
179
+ bytes memory _blob = StoreSwitch.getRecord(_tableId, _keyTuple, getValueSchema());
186
180
  return decode(_blob);
187
181
  }
188
182
 
@@ -191,7 +185,7 @@ library Position {
191
185
  bytes32[] memory _keyTuple = new bytes32[](1);
192
186
  _keyTuple[0] = key;
193
187
 
194
- bytes memory _blob = _store.getRecord(_tableId, _keyTuple, getSchema());
188
+ bytes memory _blob = _store.getRecord(_tableId, _keyTuple, getValueSchema());
195
189
  return decode(_blob);
196
190
  }
197
191
 
@@ -202,7 +196,7 @@ library Position {
202
196
  bytes32[] memory _keyTuple = new bytes32[](1);
203
197
  _keyTuple[0] = key;
204
198
 
205
- StoreSwitch.setRecord(_tableId, _keyTuple, _data);
199
+ StoreSwitch.setRecord(_tableId, _keyTuple, _data, getValueSchema());
206
200
  }
207
201
 
208
202
  /** Set the full data using individual values (using the specified store) */
@@ -212,7 +206,7 @@ library Position {
212
206
  bytes32[] memory _keyTuple = new bytes32[](1);
213
207
  _keyTuple[0] = key;
214
208
 
215
- _store.setRecord(_tableId, _keyTuple, _data);
209
+ _store.setRecord(_tableId, _keyTuple, _data, getValueSchema());
216
210
  }
217
211
 
218
212
  /** Set the full data using the data struct */
@@ -240,9 +234,11 @@ library Position {
240
234
  }
241
235
 
242
236
  /** Encode keys as a bytes32 array using this table's schema */
243
- function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) {
244
- _keyTuple = new bytes32[](1);
237
+ function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) {
238
+ bytes32[] memory _keyTuple = new bytes32[](1);
245
239
  _keyTuple[0] = key;
240
+
241
+ return _keyTuple;
246
242
  }
247
243
 
248
244
  /* Delete all data for given keys */
@@ -250,7 +246,7 @@ library Position {
250
246
  bytes32[] memory _keyTuple = new bytes32[](1);
251
247
  _keyTuple[0] = key;
252
248
 
253
- StoreSwitch.deleteRecord(_tableId, _keyTuple);
249
+ StoreSwitch.deleteRecord(_tableId, _keyTuple, getValueSchema());
254
250
  }
255
251
 
256
252
  /* Delete all data for given keys (using the specified store) */
@@ -258,6 +254,6 @@ library Position {
258
254
  bytes32[] memory _keyTuple = new bytes32[](1);
259
255
  _keyTuple[0] = key;
260
256
 
261
- _store.deleteRecord(_tableId, _keyTuple);
257
+ _store.deleteRecord(_tableId, _keyTuple, getValueSchema());
262
258
  }
263
259
  }
@@ -14,10 +14,9 @@
14
14
  "@ethersproject/providers": "^5.7.2",
15
15
  "@latticexyz/common": "{{mud-version}}",
16
16
  "@latticexyz/dev-tools": "{{mud-version}}",
17
- "@latticexyz/network": "{{mud-version}}",
18
17
  "@latticexyz/recs": "{{mud-version}}",
19
18
  "@latticexyz/schema-type": "{{mud-version}}",
20
- "@latticexyz/std-client": "{{mud-version}}",
19
+ "@latticexyz/services": "{{mud-version}}",
21
20
  "@latticexyz/store-sync": "{{mud-version}}",
22
21
  "@latticexyz/utils": "{{mud-version}}",
23
22
  "@latticexyz/world": "{{mud-version}}",
@@ -1,4 +1,4 @@
1
- import { getBurnerWallet } from "@latticexyz/std-client";
1
+ import { getBurnerPrivateKey } from "@latticexyz/common";
2
2
  import worldsJson from "contracts/worlds.json";
3
3
  import { supportedChains } from "./supportedChains";
4
4
 
@@ -24,7 +24,7 @@ export async function getNetworkConfig() {
24
24
  : world?.blockNumber ?? 0n;
25
25
 
26
26
  return {
27
- privateKey: getBurnerWallet().value,
27
+ privateKey: getBurnerPrivateKey(),
28
28
  chainId,
29
29
  chain,
30
30
  faucetServiceUrl: params.get("faucet") ?? chain.faucetUrl,
@@ -1,5 +1,5 @@
1
1
  import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, parseEther, ClientConfig } from "viem";
2
- import { createFaucetService } from "@latticexyz/network";
2
+ import { createFaucetService } from "@latticexyz/services/faucet";
3
3
  import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs";
4
4
  import { getNetworkConfig } from "./getNetworkConfig";
5
5
  import { world } from "./world";
@@ -21,54 +21,47 @@ bytes32 constant _tableId = bytes32(abi.encodePacked(bytes16(""), bytes16("Count
21
21
  bytes32 constant CounterTableId = _tableId;
22
22
 
23
23
  library Counter {
24
- /** Get the table's schema */
25
- function getSchema() internal pure returns (Schema) {
26
- SchemaType[] memory _schema = new SchemaType[](1);
27
- _schema[0] = SchemaType.UINT32;
28
-
29
- return SchemaLib.encode(_schema);
30
- }
31
-
24
+ /** Get the table's key schema */
32
25
  function getKeySchema() internal pure returns (Schema) {
33
26
  SchemaType[] memory _schema = new SchemaType[](0);
34
27
 
35
28
  return SchemaLib.encode(_schema);
36
29
  }
37
30
 
38
- /** Get the table's metadata */
39
- function getMetadata() internal pure returns (string memory, string[] memory) {
40
- string[] memory _fieldNames = new string[](1);
41
- _fieldNames[0] = "value";
42
- return ("Counter", _fieldNames);
31
+ /** Get the table's value schema */
32
+ function getValueSchema() internal pure returns (Schema) {
33
+ SchemaType[] memory _schema = new SchemaType[](1);
34
+ _schema[0] = SchemaType.UINT32;
35
+
36
+ return SchemaLib.encode(_schema);
43
37
  }
44
38
 
45
- /** Register the table's schema */
46
- function registerSchema() internal {
47
- StoreSwitch.registerSchema(_tableId, getSchema(), getKeySchema());
39
+ /** Get the table's key names */
40
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
41
+ keyNames = new string[](0);
48
42
  }
49
43
 
50
- /** Register the table's schema (using the specified store) */
51
- function registerSchema(IStore _store) internal {
52
- _store.registerSchema(_tableId, getSchema(), getKeySchema());
44
+ /** Get the table's field names */
45
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
46
+ fieldNames = new string[](1);
47
+ fieldNames[0] = "value";
53
48
  }
54
49
 
55
- /** Set the table's metadata */
56
- function setMetadata() internal {
57
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
58
- StoreSwitch.setMetadata(_tableId, _tableName, _fieldNames);
50
+ /** Register the table's key schema, value schema, key names and value names */
51
+ function register() internal {
52
+ StoreSwitch.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
59
53
  }
60
54
 
61
- /** Set the table's metadata (using the specified store) */
62
- function setMetadata(IStore _store) internal {
63
- (string memory _tableName, string[] memory _fieldNames) = getMetadata();
64
- _store.setMetadata(_tableId, _tableName, _fieldNames);
55
+ /** Register the table's key schema, value schema, key names and value names (using the specified store) */
56
+ function register(IStore _store) internal {
57
+ _store.registerTable(_tableId, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
65
58
  }
66
59
 
67
60
  /** Get value */
68
61
  function get() internal view returns (uint32 value) {
69
62
  bytes32[] memory _keyTuple = new bytes32[](0);
70
63
 
71
- bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0);
64
+ bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getValueSchema());
72
65
  return (uint32(Bytes.slice4(_blob, 0)));
73
66
  }
74
67
 
@@ -76,7 +69,7 @@ library Counter {
76
69
  function get(IStore _store) internal view returns (uint32 value) {
77
70
  bytes32[] memory _keyTuple = new bytes32[](0);
78
71
 
79
- bytes memory _blob = _store.getField(_tableId, _keyTuple, 0);
72
+ bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getValueSchema());
80
73
  return (uint32(Bytes.slice4(_blob, 0)));
81
74
  }
82
75
 
@@ -84,14 +77,14 @@ library Counter {
84
77
  function set(uint32 value) internal {
85
78
  bytes32[] memory _keyTuple = new bytes32[](0);
86
79
 
87
- StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)));
80
+ StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getValueSchema());
88
81
  }
89
82
 
90
83
  /** Set value (using the specified store) */
91
84
  function set(IStore _store, uint32 value) internal {
92
85
  bytes32[] memory _keyTuple = new bytes32[](0);
93
86
 
94
- _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)));
87
+ _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getValueSchema());
95
88
  }
96
89
 
97
90
  /** Tightly pack full data using this table's schema */
@@ -100,21 +93,23 @@ library Counter {
100
93
  }
101
94
 
102
95
  /** Encode keys as a bytes32 array using this table's schema */
103
- function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) {
104
- _keyTuple = new bytes32[](0);
96
+ function encodeKeyTuple() internal pure returns (bytes32[] memory) {
97
+ bytes32[] memory _keyTuple = new bytes32[](0);
98
+
99
+ return _keyTuple;
105
100
  }
106
101
 
107
102
  /* Delete all data for given keys */
108
103
  function deleteRecord() internal {
109
104
  bytes32[] memory _keyTuple = new bytes32[](0);
110
105
 
111
- StoreSwitch.deleteRecord(_tableId, _keyTuple);
106
+ StoreSwitch.deleteRecord(_tableId, _keyTuple, getValueSchema());
112
107
  }
113
108
 
114
109
  /* Delete all data for given keys (using the specified store) */
115
110
  function deleteRecord(IStore _store) internal {
116
111
  bytes32[] memory _keyTuple = new bytes32[](0);
117
112
 
118
- _store.deleteRecord(_tableId, _keyTuple);
113
+ _store.deleteRecord(_tableId, _keyTuple, getValueSchema());
119
114
  }
120
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mud",
3
- "version": "2.0.0-next.2",
3
+ "version": "2.0.0-next.3",
4
4
  "description": "Create a new MUD project",
5
5
  "license": "MIT",
6
6
  "author": "Lattice <mud@lattice.xyz>",