@latticexyz/cli 2.0.0-alpha.93 → 2.0.0-foundry-js-c7b0289b
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/chunk-22IIKR4S.js +4 -0
- package/dist/chunk-22IIKR4S.js.map +1 -0
- package/dist/commands-UYAATBY6.js +27 -0
- package/dist/commands-UYAATBY6.js.map +1 -0
- package/dist/errors-XGN6V2Y3.js +2 -0
- package/dist/errors-XGN6V2Y3.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/mud.js +2 -8340
- package/dist/mud.js.map +1 -0
- package/package.json +54 -46
- package/src/commands/deploy.ts +26 -0
- package/src/commands/dev-contracts.ts +114 -0
- package/src/commands/devnode.ts +7 -2
- package/src/commands/faucet.ts +1 -1
- package/src/commands/index.ts +19 -14
- package/src/commands/set-version.ts +103 -81
- package/src/commands/tablegen.ts +7 -5
- package/src/commands/test.ts +65 -0
- package/src/commands/trace.ts +118 -0
- package/src/commands/worldgen.ts +29 -28
- package/src/common.ts +1 -0
- package/src/debug.ts +3 -0
- package/src/deploy/assertNamespaceOwner.ts +42 -0
- package/src/deploy/common.ts +76 -0
- package/src/deploy/configToTables.ts +68 -0
- package/src/deploy/create2/README.md +9 -0
- package/src/deploy/create2/deployment.json +7 -0
- package/src/deploy/debug.ts +3 -0
- package/src/deploy/deploy.ts +108 -0
- package/src/deploy/deployWorld.ts +33 -0
- package/src/deploy/ensureContract.ts +61 -0
- package/src/deploy/ensureContractsDeployed.ts +25 -0
- package/src/deploy/ensureDeployer.ts +36 -0
- package/src/deploy/ensureFunctions.ts +86 -0
- package/src/deploy/ensureModules.ts +73 -0
- package/src/deploy/ensureSystems.ts +162 -0
- package/src/deploy/ensureTables.ts +65 -0
- package/src/deploy/ensureWorldFactory.ts +47 -0
- package/src/deploy/getFunctions.ts +58 -0
- package/src/deploy/getResourceAccess.ts +51 -0
- package/src/deploy/getResourceIds.ts +31 -0
- package/src/deploy/getSystems.ts +48 -0
- package/src/deploy/getTableValue.ts +30 -0
- package/src/deploy/getTables.ts +59 -0
- package/src/deploy/getWorldDeploy.ts +39 -0
- package/src/deploy/logsToWorldDeploy.ts +49 -0
- package/src/deploy/resolveConfig.ts +151 -0
- package/src/deploy/resourceLabel.ts +3 -0
- package/src/index.ts +1 -1
- package/src/modules.d.ts +11 -0
- package/src/mud.ts +38 -23
- package/src/mudPackages.ts +24 -0
- package/src/runDeploy.ts +128 -0
- package/src/utils/errors.ts +1 -1
- package/src/utils/getExistingContracts.ts +12 -0
- package/src/utils/modules/constants.ts +26 -0
- package/src/utils/printMUD.ts +14 -0
- package/src/utils/utils/getContractData.ts +32 -0
- package/src/utils/utils/postDeploy.ts +25 -0
- package/dist/chunk-6V563IAZ.js +0 -283
- package/dist/chunk-FPG73MVN.js +0 -71
- package/dist/chunk-L4YLJHLJ.js +0 -30
- package/dist/chunk-P5YXGXRI.js +0 -3842
- package/dist/chunk-SKNB74MT.js +0 -726
- package/dist/chunk-VQTZJIFF.js +0 -353
- package/dist/chunk-WZFXLDPK.js +0 -761
- package/dist/chunk-YL4GJLLL.js +0 -26139
- package/dist/index.d.ts +0 -2
- package/dist/mud.d.ts +0 -1
- package/dist/mud2.d.ts +0 -1
- package/dist/mud2.js +0 -25
- package/dist/render-solidity/index.d.ts +0 -171
- package/dist/render-solidity/index.js +0 -49
- package/dist/render-ts/index.d.ts +0 -26
- package/dist/render-ts/index.js +0 -14
- package/dist/utils/deprecated/index.d.ts +0 -76
- package/dist/utils/deprecated/index.js +0 -36
- package/dist/utils/index.d.ts +0 -88
- package/dist/utils/index.js +0 -39
- package/src/commands/deploy-v2.ts +0 -112
- package/src/commands/deprecated/bulkupload.ts +0 -50
- package/src/commands/deprecated/call-system.ts +0 -70
- package/src/commands/deprecated/codegen-libdeploy.ts +0 -29
- package/src/commands/deprecated/deploy-contracts.ts +0 -120
- package/src/commands/deprecated/index.ts +0 -22
- package/src/commands/deprecated/system-types.ts +0 -29
- package/src/commands/deprecated/test.ts +0 -53
- package/src/commands/deprecated/trace.ts +0 -81
- package/src/commands/deprecated/types.ts +0 -33
- package/src/commands/gas-report.ts +0 -219
- package/src/commands/test-v2.ts +0 -71
- package/src/commands/tsgen.ts +0 -33
- package/src/contracts/BulkUpload.sol +0 -174
- package/src/contracts/Deploy.sol +0 -23
- package/src/contracts/LibDeploy.ejs +0 -121
- package/src/contracts/LibDeploy.sol +0 -23
- package/src/contracts/LibDeployStub.sol +0 -23
- package/src/mud2.ts +0 -29
- package/src/render-solidity/common.ts +0 -138
- package/src/render-solidity/field.ts +0 -160
- package/src/render-solidity/index.ts +0 -10
- package/src/render-solidity/record.ts +0 -158
- package/src/render-solidity/renderSystemInterface.ts +0 -31
- package/src/render-solidity/renderTable.ts +0 -164
- package/src/render-solidity/renderTableIndex.ts +0 -15
- package/src/render-solidity/renderTypeHelpers.ts +0 -99
- package/src/render-solidity/renderTypes.ts +0 -19
- package/src/render-solidity/renderTypesFromConfig.ts +0 -13
- package/src/render-solidity/renderWorld.ts +0 -24
- package/src/render-solidity/tableOptions.ts +0 -107
- package/src/render-solidity/tablegen.ts +0 -35
- package/src/render-solidity/types.ts +0 -111
- package/src/render-solidity/userType.ts +0 -131
- package/src/render-solidity/worldgen.ts +0 -59
- package/src/render-ts/index.ts +0 -5
- package/src/render-ts/recsV1TableOptions.ts +0 -39
- package/src/render-ts/renderRecsV1Tables.ts +0 -31
- package/src/render-ts/schemaTypesToRecsTypeStrings.ts +0 -202
- package/src/render-ts/tsgen.ts +0 -12
- package/src/render-ts/types.ts +0 -13
- package/src/utils/contractToInterface.ts +0 -132
- package/src/utils/deploy-v2.ts +0 -518
- package/src/utils/deprecated/build.ts +0 -55
- package/src/utils/deprecated/codegen.ts +0 -42
- package/src/utils/deprecated/constants.ts +0 -2
- package/src/utils/deprecated/deploy.ts +0 -111
- package/src/utils/deprecated/exec.ts +0 -18
- package/src/utils/deprecated/findLog.ts +0 -8
- package/src/utils/deprecated/hsr.ts +0 -71
- package/src/utils/deprecated/ids.ts +0 -14
- package/src/utils/deprecated/index.ts +0 -8
- package/src/utils/deprecated/typegen.ts +0 -133
- package/src/utils/execLog.ts +0 -22
- package/src/utils/format.ts +0 -39
- package/src/utils/formatAndWrite.ts +0 -21
- package/src/utils/foundry.ts +0 -103
- package/src/utils/getChainId.ts +0 -10
- package/src/utils/index.ts +0 -5
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import glob from "glob";
|
|
2
|
+
import { basename } from "path";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get a list of all contract paths/names within the provided src directory
|
|
6
|
+
*/
|
|
7
|
+
export function getExistingContracts(srcDir: string) {
|
|
8
|
+
return glob.sync(`${srcDir}/**/*.sol`).map((path) => ({
|
|
9
|
+
path,
|
|
10
|
+
basename: basename(path, ".sol"),
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import KeysWithValueModuleData from "@latticexyz/world-modules/out/KeysWithValueModule.sol/KeysWithValueModule.json" assert { type: "json" };
|
|
2
|
+
import KeysInTableModuleData from "@latticexyz/world-modules/out/KeysInTableModule.sol/KeysInTableModule.json" assert { type: "json" };
|
|
3
|
+
import UniqueEntityModuleData from "@latticexyz/world-modules/out/UniqueEntityModule.sol/UniqueEntityModule.json" assert { type: "json" };
|
|
4
|
+
import { Abi, Hex, size } from "viem";
|
|
5
|
+
|
|
6
|
+
// These modules are always deployed
|
|
7
|
+
export const defaultModuleContracts = [
|
|
8
|
+
{
|
|
9
|
+
name: "KeysWithValueModule",
|
|
10
|
+
abi: KeysWithValueModuleData.abi as Abi,
|
|
11
|
+
bytecode: KeysWithValueModuleData.bytecode.object as Hex,
|
|
12
|
+
deployedBytecodeSize: size(KeysWithValueModuleData.deployedBytecode.object as Hex),
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "KeysInTableModule",
|
|
16
|
+
abi: KeysInTableModuleData.abi as Abi,
|
|
17
|
+
bytecode: KeysInTableModuleData.bytecode.object as Hex,
|
|
18
|
+
deployedBytecodeSize: size(KeysInTableModuleData.deployedBytecode.object as Hex),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "UniqueEntityModule",
|
|
22
|
+
abi: UniqueEntityModuleData.abi as Abi,
|
|
23
|
+
bytecode: UniqueEntityModuleData.bytecode.object as Hex,
|
|
24
|
+
deployedBytecodeSize: size(UniqueEntityModuleData.deployedBytecode.object as Hex),
|
|
25
|
+
},
|
|
26
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
|
|
3
|
+
export function printMUD() {
|
|
4
|
+
console.log(
|
|
5
|
+
chalk.yellow(`
|
|
6
|
+
.------..------..------.
|
|
7
|
+
|M.--. ||U.--. ||D.--. |
|
|
8
|
+
| (\\/) || (\\/) || :/\\: |
|
|
9
|
+
| :\\/: || :\\/: || (__) |
|
|
10
|
+
| '--'M|| '--'U|| '--'D|
|
|
11
|
+
'------''------''------'
|
|
12
|
+
`)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { MUDError } from "@latticexyz/common/errors";
|
|
4
|
+
import { Abi, Hex, size } from "viem";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Load the contract's abi and bytecode from the file system
|
|
8
|
+
* @param contractName: Name of the contract to load
|
|
9
|
+
*/
|
|
10
|
+
export function getContractData(
|
|
11
|
+
contractName: string,
|
|
12
|
+
forgeOutDirectory: string
|
|
13
|
+
): { bytecode: Hex; abi: Abi; deployedBytecodeSize: number } {
|
|
14
|
+
let data: any;
|
|
15
|
+
const contractDataPath = path.join(forgeOutDirectory, contractName + ".sol", contractName + ".json");
|
|
16
|
+
try {
|
|
17
|
+
data = JSON.parse(readFileSync(contractDataPath, "utf8"));
|
|
18
|
+
} catch (error: any) {
|
|
19
|
+
throw new MUDError(`Error reading file at ${contractDataPath}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bytecode = data?.bytecode?.object;
|
|
23
|
+
if (!bytecode) throw new MUDError(`No bytecode found in ${contractDataPath}`);
|
|
24
|
+
|
|
25
|
+
const deployedBytecode = data?.deployedBytecode?.object;
|
|
26
|
+
if (!deployedBytecode) throw new MUDError(`No deployed bytecode found in ${contractDataPath}`);
|
|
27
|
+
|
|
28
|
+
const abi = data?.abi;
|
|
29
|
+
if (!abi) throw new MUDError(`No ABI found in ${contractDataPath}`);
|
|
30
|
+
|
|
31
|
+
return { abi, bytecode, deployedBytecodeSize: size(deployedBytecode as Hex) };
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { getScriptDirectory, forge } from "@latticexyz/common/foundry";
|
|
5
|
+
|
|
6
|
+
export async function postDeploy(
|
|
7
|
+
postDeployScript: string,
|
|
8
|
+
worldAddress: string,
|
|
9
|
+
rpc: string,
|
|
10
|
+
profile: string | undefined
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
// Execute postDeploy forge script
|
|
13
|
+
const postDeployPath = path.join(await getScriptDirectory(), postDeployScript + ".s.sol");
|
|
14
|
+
if (existsSync(postDeployPath)) {
|
|
15
|
+
console.log(chalk.blue(`Executing post deploy script at ${postDeployPath}`));
|
|
16
|
+
await forge(
|
|
17
|
+
["script", postDeployScript, "--sig", "run(address)", worldAddress, "--broadcast", "--rpc-url", rpc, "-vvv"],
|
|
18
|
+
{
|
|
19
|
+
profile: profile,
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
} else {
|
|
23
|
+
console.log(`No script at ${postDeployPath}, skipping post deploy hook`);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/dist/chunk-6V563IAZ.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatAndWriteTypescript,
|
|
3
|
-
resolveAbiOrUserType
|
|
4
|
-
} from "./chunk-SKNB74MT.js";
|
|
5
|
-
|
|
6
|
-
// src/render-ts/schemaTypesToRecsTypeStrings.ts
|
|
7
|
-
var schemaTypesToRecsTypeStrings = {
|
|
8
|
-
[0 /* UINT8 */]: "RecsType.Number",
|
|
9
|
-
[1 /* UINT16 */]: "RecsType.Number",
|
|
10
|
-
[2 /* UINT24 */]: "RecsType.Number",
|
|
11
|
-
[3 /* UINT32 */]: "RecsType.Number",
|
|
12
|
-
[4 /* UINT40 */]: "RecsType.Number",
|
|
13
|
-
[5 /* UINT48 */]: "RecsType.Number",
|
|
14
|
-
[6 /* UINT56 */]: "RecsType.BigInt",
|
|
15
|
-
[7 /* UINT64 */]: "RecsType.BigInt",
|
|
16
|
-
[8 /* UINT72 */]: "RecsType.BigInt",
|
|
17
|
-
[9 /* UINT80 */]: "RecsType.BigInt",
|
|
18
|
-
[10 /* UINT88 */]: "RecsType.BigInt",
|
|
19
|
-
[11 /* UINT96 */]: "RecsType.BigInt",
|
|
20
|
-
[12 /* UINT104 */]: "RecsType.BigInt",
|
|
21
|
-
[13 /* UINT112 */]: "RecsType.BigInt",
|
|
22
|
-
[14 /* UINT120 */]: "RecsType.BigInt",
|
|
23
|
-
[15 /* UINT128 */]: "RecsType.BigInt",
|
|
24
|
-
[16 /* UINT136 */]: "RecsType.BigInt",
|
|
25
|
-
[17 /* UINT144 */]: "RecsType.BigInt",
|
|
26
|
-
[18 /* UINT152 */]: "RecsType.BigInt",
|
|
27
|
-
[19 /* UINT160 */]: "RecsType.BigInt",
|
|
28
|
-
[20 /* UINT168 */]: "RecsType.BigInt",
|
|
29
|
-
[21 /* UINT176 */]: "RecsType.BigInt",
|
|
30
|
-
[22 /* UINT184 */]: "RecsType.BigInt",
|
|
31
|
-
[23 /* UINT192 */]: "RecsType.BigInt",
|
|
32
|
-
[24 /* UINT200 */]: "RecsType.BigInt",
|
|
33
|
-
[25 /* UINT208 */]: "RecsType.BigInt",
|
|
34
|
-
[26 /* UINT216 */]: "RecsType.BigInt",
|
|
35
|
-
[27 /* UINT224 */]: "RecsType.BigInt",
|
|
36
|
-
[28 /* UINT232 */]: "RecsType.BigInt",
|
|
37
|
-
[29 /* UINT240 */]: "RecsType.BigInt",
|
|
38
|
-
[30 /* UINT248 */]: "RecsType.BigInt",
|
|
39
|
-
[31 /* UINT256 */]: "RecsType.BigInt",
|
|
40
|
-
[32 /* INT8 */]: "RecsType.Number",
|
|
41
|
-
[33 /* INT16 */]: "RecsType.Number",
|
|
42
|
-
[34 /* INT24 */]: "RecsType.Number",
|
|
43
|
-
[35 /* INT32 */]: "RecsType.Number",
|
|
44
|
-
[36 /* INT40 */]: "RecsType.Number",
|
|
45
|
-
[37 /* INT48 */]: "RecsType.Number",
|
|
46
|
-
[38 /* INT56 */]: "RecsType.BigInt",
|
|
47
|
-
[39 /* INT64 */]: "RecsType.BigInt",
|
|
48
|
-
[40 /* INT72 */]: "RecsType.BigInt",
|
|
49
|
-
[41 /* INT80 */]: "RecsType.BigInt",
|
|
50
|
-
[42 /* INT88 */]: "RecsType.BigInt",
|
|
51
|
-
[43 /* INT96 */]: "RecsType.BigInt",
|
|
52
|
-
[44 /* INT104 */]: "RecsType.BigInt",
|
|
53
|
-
[45 /* INT112 */]: "RecsType.BigInt",
|
|
54
|
-
[46 /* INT120 */]: "RecsType.BigInt",
|
|
55
|
-
[47 /* INT128 */]: "RecsType.BigInt",
|
|
56
|
-
[48 /* INT136 */]: "RecsType.BigInt",
|
|
57
|
-
[49 /* INT144 */]: "RecsType.BigInt",
|
|
58
|
-
[50 /* INT152 */]: "RecsType.BigInt",
|
|
59
|
-
[51 /* INT160 */]: "RecsType.BigInt",
|
|
60
|
-
[52 /* INT168 */]: "RecsType.BigInt",
|
|
61
|
-
[53 /* INT176 */]: "RecsType.BigInt",
|
|
62
|
-
[54 /* INT184 */]: "RecsType.BigInt",
|
|
63
|
-
[55 /* INT192 */]: "RecsType.BigInt",
|
|
64
|
-
[56 /* INT200 */]: "RecsType.BigInt",
|
|
65
|
-
[57 /* INT208 */]: "RecsType.BigInt",
|
|
66
|
-
[58 /* INT216 */]: "RecsType.BigInt",
|
|
67
|
-
[59 /* INT224 */]: "RecsType.BigInt",
|
|
68
|
-
[60 /* INT232 */]: "RecsType.BigInt",
|
|
69
|
-
[61 /* INT240 */]: "RecsType.BigInt",
|
|
70
|
-
[62 /* INT248 */]: "RecsType.BigInt",
|
|
71
|
-
[63 /* INT256 */]: "RecsType.BigInt",
|
|
72
|
-
[64 /* BYTES1 */]: "RecsType.String",
|
|
73
|
-
[65 /* BYTES2 */]: "RecsType.String",
|
|
74
|
-
[66 /* BYTES3 */]: "RecsType.String",
|
|
75
|
-
[67 /* BYTES4 */]: "RecsType.String",
|
|
76
|
-
[68 /* BYTES5 */]: "RecsType.String",
|
|
77
|
-
[69 /* BYTES6 */]: "RecsType.String",
|
|
78
|
-
[70 /* BYTES7 */]: "RecsType.String",
|
|
79
|
-
[71 /* BYTES8 */]: "RecsType.String",
|
|
80
|
-
[72 /* BYTES9 */]: "RecsType.String",
|
|
81
|
-
[73 /* BYTES10 */]: "RecsType.String",
|
|
82
|
-
[74 /* BYTES11 */]: "RecsType.String",
|
|
83
|
-
[75 /* BYTES12 */]: "RecsType.String",
|
|
84
|
-
[76 /* BYTES13 */]: "RecsType.String",
|
|
85
|
-
[77 /* BYTES14 */]: "RecsType.String",
|
|
86
|
-
[78 /* BYTES15 */]: "RecsType.String",
|
|
87
|
-
[79 /* BYTES16 */]: "RecsType.String",
|
|
88
|
-
[80 /* BYTES17 */]: "RecsType.String",
|
|
89
|
-
[81 /* BYTES18 */]: "RecsType.String",
|
|
90
|
-
[82 /* BYTES19 */]: "RecsType.String",
|
|
91
|
-
[83 /* BYTES20 */]: "RecsType.String",
|
|
92
|
-
[84 /* BYTES21 */]: "RecsType.String",
|
|
93
|
-
[85 /* BYTES22 */]: "RecsType.String",
|
|
94
|
-
[86 /* BYTES23 */]: "RecsType.String",
|
|
95
|
-
[87 /* BYTES24 */]: "RecsType.String",
|
|
96
|
-
[88 /* BYTES25 */]: "RecsType.String",
|
|
97
|
-
[89 /* BYTES26 */]: "RecsType.String",
|
|
98
|
-
[90 /* BYTES27 */]: "RecsType.String",
|
|
99
|
-
[91 /* BYTES28 */]: "RecsType.String",
|
|
100
|
-
[92 /* BYTES29 */]: "RecsType.String",
|
|
101
|
-
[93 /* BYTES30 */]: "RecsType.String",
|
|
102
|
-
[94 /* BYTES31 */]: "RecsType.String",
|
|
103
|
-
[95 /* BYTES32 */]: "RecsType.String",
|
|
104
|
-
[96 /* BOOL */]: "RecsType.Boolean",
|
|
105
|
-
[97 /* ADDRESS */]: "RecsType.String",
|
|
106
|
-
[98 /* UINT8_ARRAY */]: "RecsType.NumberArray",
|
|
107
|
-
[99 /* UINT16_ARRAY */]: "RecsType.NumberArray",
|
|
108
|
-
[100 /* UINT24_ARRAY */]: "RecsType.NumberArray",
|
|
109
|
-
[101 /* UINT32_ARRAY */]: "RecsType.NumberArray",
|
|
110
|
-
[102 /* UINT40_ARRAY */]: "RecsType.NumberArray",
|
|
111
|
-
[103 /* UINT48_ARRAY */]: "RecsType.NumberArray",
|
|
112
|
-
[104 /* UINT56_ARRAY */]: "RecsType.BigIntArray",
|
|
113
|
-
[105 /* UINT64_ARRAY */]: "RecsType.BigIntArray",
|
|
114
|
-
[106 /* UINT72_ARRAY */]: "RecsType.BigIntArray",
|
|
115
|
-
[107 /* UINT80_ARRAY */]: "RecsType.BigIntArray",
|
|
116
|
-
[108 /* UINT88_ARRAY */]: "RecsType.BigIntArray",
|
|
117
|
-
[109 /* UINT96_ARRAY */]: "RecsType.BigIntArray",
|
|
118
|
-
[110 /* UINT104_ARRAY */]: "RecsType.BigIntArray",
|
|
119
|
-
[111 /* UINT112_ARRAY */]: "RecsType.BigIntArray",
|
|
120
|
-
[112 /* UINT120_ARRAY */]: "RecsType.BigIntArray",
|
|
121
|
-
[113 /* UINT128_ARRAY */]: "RecsType.BigIntArray",
|
|
122
|
-
[114 /* UINT136_ARRAY */]: "RecsType.BigIntArray",
|
|
123
|
-
[115 /* UINT144_ARRAY */]: "RecsType.BigIntArray",
|
|
124
|
-
[116 /* UINT152_ARRAY */]: "RecsType.BigIntArray",
|
|
125
|
-
[117 /* UINT160_ARRAY */]: "RecsType.BigIntArray",
|
|
126
|
-
[118 /* UINT168_ARRAY */]: "RecsType.BigIntArray",
|
|
127
|
-
[119 /* UINT176_ARRAY */]: "RecsType.BigIntArray",
|
|
128
|
-
[120 /* UINT184_ARRAY */]: "RecsType.BigIntArray",
|
|
129
|
-
[121 /* UINT192_ARRAY */]: "RecsType.BigIntArray",
|
|
130
|
-
[122 /* UINT200_ARRAY */]: "RecsType.BigIntArray",
|
|
131
|
-
[123 /* UINT208_ARRAY */]: "RecsType.BigIntArray",
|
|
132
|
-
[124 /* UINT216_ARRAY */]: "RecsType.BigIntArray",
|
|
133
|
-
[125 /* UINT224_ARRAY */]: "RecsType.BigIntArray",
|
|
134
|
-
[126 /* UINT232_ARRAY */]: "RecsType.BigIntArray",
|
|
135
|
-
[127 /* UINT240_ARRAY */]: "RecsType.BigIntArray",
|
|
136
|
-
[128 /* UINT248_ARRAY */]: "RecsType.BigIntArray",
|
|
137
|
-
[129 /* UINT256_ARRAY */]: "RecsType.BigIntArray",
|
|
138
|
-
[130 /* INT8_ARRAY */]: "RecsType.NumberArray",
|
|
139
|
-
[131 /* INT16_ARRAY */]: "RecsType.NumberArray",
|
|
140
|
-
[132 /* INT24_ARRAY */]: "RecsType.NumberArray",
|
|
141
|
-
[133 /* INT32_ARRAY */]: "RecsType.NumberArray",
|
|
142
|
-
[134 /* INT40_ARRAY */]: "RecsType.NumberArray",
|
|
143
|
-
[135 /* INT48_ARRAY */]: "RecsType.NumberArray",
|
|
144
|
-
[136 /* INT56_ARRAY */]: "RecsType.BigIntArray",
|
|
145
|
-
[137 /* INT64_ARRAY */]: "RecsType.BigIntArray",
|
|
146
|
-
[138 /* INT72_ARRAY */]: "RecsType.BigIntArray",
|
|
147
|
-
[139 /* INT80_ARRAY */]: "RecsType.BigIntArray",
|
|
148
|
-
[140 /* INT88_ARRAY */]: "RecsType.BigIntArray",
|
|
149
|
-
[141 /* INT96_ARRAY */]: "RecsType.BigIntArray",
|
|
150
|
-
[142 /* INT104_ARRAY */]: "RecsType.BigIntArray",
|
|
151
|
-
[143 /* INT112_ARRAY */]: "RecsType.BigIntArray",
|
|
152
|
-
[144 /* INT120_ARRAY */]: "RecsType.BigIntArray",
|
|
153
|
-
[145 /* INT128_ARRAY */]: "RecsType.BigIntArray",
|
|
154
|
-
[146 /* INT136_ARRAY */]: "RecsType.BigIntArray",
|
|
155
|
-
[147 /* INT144_ARRAY */]: "RecsType.BigIntArray",
|
|
156
|
-
[148 /* INT152_ARRAY */]: "RecsType.BigIntArray",
|
|
157
|
-
[149 /* INT160_ARRAY */]: "RecsType.BigIntArray",
|
|
158
|
-
[150 /* INT168_ARRAY */]: "RecsType.BigIntArray",
|
|
159
|
-
[151 /* INT176_ARRAY */]: "RecsType.BigIntArray",
|
|
160
|
-
[152 /* INT184_ARRAY */]: "RecsType.BigIntArray",
|
|
161
|
-
[153 /* INT192_ARRAY */]: "RecsType.BigIntArray",
|
|
162
|
-
[154 /* INT200_ARRAY */]: "RecsType.BigIntArray",
|
|
163
|
-
[155 /* INT208_ARRAY */]: "RecsType.BigIntArray",
|
|
164
|
-
[156 /* INT216_ARRAY */]: "RecsType.BigIntArray",
|
|
165
|
-
[157 /* INT224_ARRAY */]: "RecsType.BigIntArray",
|
|
166
|
-
[158 /* INT232_ARRAY */]: "RecsType.BigIntArray",
|
|
167
|
-
[159 /* INT240_ARRAY */]: "RecsType.BigIntArray",
|
|
168
|
-
[160 /* INT248_ARRAY */]: "RecsType.BigIntArray",
|
|
169
|
-
[161 /* INT256_ARRAY */]: "RecsType.BigIntArray",
|
|
170
|
-
[162 /* BYTES1_ARRAY */]: "RecsType.BigIntArray",
|
|
171
|
-
[163 /* BYTES2_ARRAY */]: "RecsType.BigIntArray",
|
|
172
|
-
[164 /* BYTES3_ARRAY */]: "RecsType.BigIntArray",
|
|
173
|
-
[165 /* BYTES4_ARRAY */]: "RecsType.BigIntArray",
|
|
174
|
-
[166 /* BYTES5_ARRAY */]: "RecsType.BigIntArray",
|
|
175
|
-
[167 /* BYTES6_ARRAY */]: "RecsType.BigIntArray",
|
|
176
|
-
[168 /* BYTES7_ARRAY */]: "RecsType.BigIntArray",
|
|
177
|
-
[169 /* BYTES8_ARRAY */]: "RecsType.BigIntArray",
|
|
178
|
-
[170 /* BYTES9_ARRAY */]: "RecsType.BigIntArray",
|
|
179
|
-
[171 /* BYTES10_ARRAY */]: "RecsType.BigIntArray",
|
|
180
|
-
[172 /* BYTES11_ARRAY */]: "RecsType.BigIntArray",
|
|
181
|
-
[173 /* BYTES12_ARRAY */]: "RecsType.BigIntArray",
|
|
182
|
-
[174 /* BYTES13_ARRAY */]: "RecsType.BigIntArray",
|
|
183
|
-
[175 /* BYTES14_ARRAY */]: "RecsType.BigIntArray",
|
|
184
|
-
[176 /* BYTES15_ARRAY */]: "RecsType.BigIntArray",
|
|
185
|
-
[177 /* BYTES16_ARRAY */]: "RecsType.BigIntArray",
|
|
186
|
-
[178 /* BYTES17_ARRAY */]: "RecsType.BigIntArray",
|
|
187
|
-
[179 /* BYTES18_ARRAY */]: "RecsType.BigIntArray",
|
|
188
|
-
[180 /* BYTES19_ARRAY */]: "RecsType.BigIntArray",
|
|
189
|
-
[181 /* BYTES20_ARRAY */]: "RecsType.BigIntArray",
|
|
190
|
-
[182 /* BYTES21_ARRAY */]: "RecsType.BigIntArray",
|
|
191
|
-
[183 /* BYTES22_ARRAY */]: "RecsType.BigIntArray",
|
|
192
|
-
[184 /* BYTES23_ARRAY */]: "RecsType.BigIntArray",
|
|
193
|
-
[185 /* BYTES24_ARRAY */]: "RecsType.BigIntArray",
|
|
194
|
-
[186 /* BYTES25_ARRAY */]: "RecsType.BigIntArray",
|
|
195
|
-
[187 /* BYTES26_ARRAY */]: "RecsType.BigIntArray",
|
|
196
|
-
[188 /* BYTES27_ARRAY */]: "RecsType.BigIntArray",
|
|
197
|
-
[189 /* BYTES28_ARRAY */]: "RecsType.BigIntArray",
|
|
198
|
-
[190 /* BYTES29_ARRAY */]: "RecsType.BigIntArray",
|
|
199
|
-
[191 /* BYTES30_ARRAY */]: "RecsType.BigIntArray",
|
|
200
|
-
[192 /* BYTES31_ARRAY */]: "RecsType.BigIntArray",
|
|
201
|
-
[193 /* BYTES32_ARRAY */]: "RecsType.BigIntArray",
|
|
202
|
-
[194 /* BOOL_ARRAY */]: "RecsType.T",
|
|
203
|
-
// no boolean array
|
|
204
|
-
[195 /* ADDRESS_ARRAY */]: "RecsType.StringArray",
|
|
205
|
-
[196 /* BYTES */]: "RecsType.String",
|
|
206
|
-
[197 /* STRING */]: "RecsType.String"
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// src/render-ts/recsV1TableOptions.ts
|
|
210
|
-
function getRecsV1TableOptions(config) {
|
|
211
|
-
const tableOptions = [];
|
|
212
|
-
for (const tableName of Object.keys(config.tables)) {
|
|
213
|
-
const tableData = config.tables[tableName];
|
|
214
|
-
const fields = Object.keys(tableData.schema).map((name) => {
|
|
215
|
-
const abiOrUserType = tableData.schema[name];
|
|
216
|
-
const { schemaType } = resolveAbiOrUserType(abiOrUserType, config);
|
|
217
|
-
const recsTypeString = schemaTypesToRecsTypeStrings[schemaType];
|
|
218
|
-
return {
|
|
219
|
-
recsTypeString,
|
|
220
|
-
name
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
if (tableData.tableIdArgument)
|
|
224
|
-
continue;
|
|
225
|
-
const staticResourceData = {
|
|
226
|
-
namespace: config.namespace,
|
|
227
|
-
name: tableData.name
|
|
228
|
-
};
|
|
229
|
-
tableOptions.push({
|
|
230
|
-
tableName,
|
|
231
|
-
fields,
|
|
232
|
-
staticResourceData
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
tables: tableOptions
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// src/render-ts/renderRecsV1Tables.ts
|
|
241
|
-
function renderRecsV1Tables(options) {
|
|
242
|
-
const { tables } = options;
|
|
243
|
-
return `/* Autogenerated file. Do not edit manually. */
|
|
244
|
-
|
|
245
|
-
import { TableId } from "@latticexyz/utils";
|
|
246
|
-
import { defineComponent, Type as RecsType, World } from "@latticexyz/recs";
|
|
247
|
-
|
|
248
|
-
export function defineContractComponents(world: World) {
|
|
249
|
-
return {
|
|
250
|
-
${tables.map((table) => `${table.tableName}: ${renderDefineComponent(table)},`).join("")}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
`;
|
|
254
|
-
}
|
|
255
|
-
function renderDefineComponent(table) {
|
|
256
|
-
const { namespace, name } = table.staticResourceData;
|
|
257
|
-
return `
|
|
258
|
-
(() => {
|
|
259
|
-
const tableId = new TableId("${namespace}", "${name}");
|
|
260
|
-
return defineComponent(world, {
|
|
261
|
-
${table.fields.map(({ name: name2, recsTypeString }) => `${name2}: ${recsTypeString},`).join("")}
|
|
262
|
-
}, {
|
|
263
|
-
metadata: { contractId: tableId.toHexString(), tableId: tableId.toString() },
|
|
264
|
-
});
|
|
265
|
-
})()
|
|
266
|
-
`;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// src/render-ts/tsgen.ts
|
|
270
|
-
import path from "path";
|
|
271
|
-
async function tsgen(config, outDirectory) {
|
|
272
|
-
const fullOutputPath = path.join(outDirectory, `contractComponents.ts`);
|
|
273
|
-
const options = getRecsV1TableOptions(config);
|
|
274
|
-
const output = renderRecsV1Tables(options);
|
|
275
|
-
formatAndWriteTypescript(output, fullOutputPath, "Generated ts definition files");
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export {
|
|
279
|
-
schemaTypesToRecsTypeStrings,
|
|
280
|
-
getRecsV1TableOptions,
|
|
281
|
-
renderRecsV1Tables,
|
|
282
|
-
tsgen
|
|
283
|
-
};
|
package/dist/chunk-FPG73MVN.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// src/utils/foundry.ts
|
|
2
|
-
import { execa as execa2 } from "execa";
|
|
3
|
-
|
|
4
|
-
// src/utils/execLog.ts
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import { execa } from "execa";
|
|
7
|
-
async function execLog(command, args, options) {
|
|
8
|
-
const commandString = `${command} ${args.join(" ")}`;
|
|
9
|
-
try {
|
|
10
|
-
console.log(chalk.gray(`running "${commandString}"`));
|
|
11
|
-
const { stdout } = await execa(command, args, { stdout: "pipe", stderr: "pipe", ...options });
|
|
12
|
-
return stdout;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
let errorMessage = error?.stderr || error?.message || "";
|
|
15
|
-
errorMessage += chalk.red(`
|
|
16
|
-
Error running "${commandString}"`);
|
|
17
|
-
throw new Error(errorMessage);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// src/utils/foundry.ts
|
|
22
|
-
async function getForgeConfig(profile) {
|
|
23
|
-
const { stdout } = await execa2("forge", ["config", "--json"], {
|
|
24
|
-
stdio: ["inherit", "pipe", "pipe"],
|
|
25
|
-
env: { FOUNDRY_PROFILE: profile }
|
|
26
|
-
});
|
|
27
|
-
return JSON.parse(stdout);
|
|
28
|
-
}
|
|
29
|
-
async function getSrcDirectory(profile) {
|
|
30
|
-
return (await getForgeConfig(profile)).src;
|
|
31
|
-
}
|
|
32
|
-
async function getScriptDirectory(profile) {
|
|
33
|
-
return (await getForgeConfig(profile)).script;
|
|
34
|
-
}
|
|
35
|
-
async function getTestDirectory(profile) {
|
|
36
|
-
return (await getForgeConfig(profile)).test;
|
|
37
|
-
}
|
|
38
|
-
async function getOutDirectory(profile) {
|
|
39
|
-
return (await getForgeConfig(profile)).out;
|
|
40
|
-
}
|
|
41
|
-
async function getRpcUrl(profile) {
|
|
42
|
-
return (await getForgeConfig(profile)).eth_rpc_url || "http://127.0.0.1:8545";
|
|
43
|
-
}
|
|
44
|
-
async function forge(args, options) {
|
|
45
|
-
const execOptions = {
|
|
46
|
-
env: { FOUNDRY_PROFILE: options?.profile },
|
|
47
|
-
stdout: "inherit",
|
|
48
|
-
stderr: "pipe"
|
|
49
|
-
};
|
|
50
|
-
await (options?.silent ? execa2("forge", args, execOptions) : execLog("forge", args, execOptions));
|
|
51
|
-
}
|
|
52
|
-
async function cast(args, options) {
|
|
53
|
-
return execLog("cast", args, {
|
|
54
|
-
env: { FOUNDRY_PROFILE: options?.profile }
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async function anvil(args) {
|
|
58
|
-
return execLog("anvil", args);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
getForgeConfig,
|
|
63
|
-
getSrcDirectory,
|
|
64
|
-
getScriptDirectory,
|
|
65
|
-
getTestDirectory,
|
|
66
|
-
getOutDirectory,
|
|
67
|
-
getRpcUrl,
|
|
68
|
-
forge,
|
|
69
|
-
cast,
|
|
70
|
-
anvil
|
|
71
|
-
};
|
package/dist/chunk-L4YLJHLJ.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
-
mod
|
|
25
|
-
));
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
__commonJS,
|
|
29
|
-
__toESM
|
|
30
|
-
};
|