@latticexyz/cli 2.0.9 → 2.0.10-230513-threejs-template-use-namespace-d6ab6d80
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/commands-RH47YCPC.js +39 -0
- package/dist/commands-RH47YCPC.js.map +1 -0
- package/dist/mud.js +1 -1
- package/package.json +14 -14
- package/src/commands/verify.ts +2 -12
- package/src/deploy/common.ts +0 -1
- package/src/deploy/configToModules.ts +81 -0
- package/src/deploy/deploy.ts +5 -3
- package/src/deploy/ensureModules.ts +3 -2
- package/src/deploy/getFunctions.ts +37 -31
- package/src/deploy/resolveConfig.ts +2 -46
- package/src/runDeploy.ts +3 -0
- package/src/utils/getContractArtifact.ts +73 -0
- package/src/utils/knownModuleArtifacts.ts +8 -0
- package/src/verify.ts +11 -13
- package/dist/commands-UILDTPAU.js +0 -38
- package/dist/commands-UILDTPAU.js.map +0 -1
- package/src/utils/defaultModuleContracts.ts +0 -39
package/src/commands/verify.ts
CHANGED
@@ -7,9 +7,9 @@ import { worldToV1 } from "@latticexyz/world/config/v2";
|
|
7
7
|
import { getOutDirectory, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry";
|
8
8
|
import { getExistingContracts } from "../utils/getExistingContracts";
|
9
9
|
import { getContractData } from "../utils/getContractData";
|
10
|
-
import { defaultModuleContracts } from "../utils/defaultModuleContracts";
|
11
10
|
import { Hex, createWalletClient, http } from "viem";
|
12
11
|
import chalk from "chalk";
|
12
|
+
import { configToModules } from "../deploy/configToModules";
|
13
13
|
|
14
14
|
const verifyOptions = {
|
15
15
|
deployerAddress: {
|
@@ -82,17 +82,7 @@ const commandModule: CommandModule<Options, Options> = {
|
|
82
82
|
};
|
83
83
|
});
|
84
84
|
|
85
|
-
|
86
|
-
const modules = config.modules.map((mod) => {
|
87
|
-
const contractData =
|
88
|
-
defaultModuleContracts.find((defaultMod) => defaultMod.name === mod.name) ??
|
89
|
-
getContractData(`${mod.name}.sol`, mod.name, outDir);
|
90
|
-
|
91
|
-
return {
|
92
|
-
name: mod.name,
|
93
|
-
bytecode: contractData.bytecode,
|
94
|
-
};
|
95
|
-
});
|
85
|
+
const modules = await configToModules(configV2, outDir);
|
96
86
|
|
97
87
|
await verify({
|
98
88
|
client,
|
package/src/deploy/common.ts
CHANGED
@@ -117,6 +117,5 @@ export type ConfigInput = StoreConfig & WorldConfig;
|
|
117
117
|
export type Config<config extends ConfigInput> = {
|
118
118
|
readonly tables: Tables<config>;
|
119
119
|
readonly systems: readonly System[];
|
120
|
-
readonly modules: readonly Module[];
|
121
120
|
readonly libraries: readonly Library[];
|
122
121
|
};
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import path from "node:path";
|
2
|
+
import { Module } from "./common";
|
3
|
+
import { resolveWithContext } from "@latticexyz/config/library";
|
4
|
+
import { encodeField } from "@latticexyz/protocol-parser/internal";
|
5
|
+
import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal";
|
6
|
+
import { bytesToHex, hexToBytes } from "viem";
|
7
|
+
import { createPrepareDeploy } from "./createPrepareDeploy";
|
8
|
+
import { World } from "@latticexyz/world";
|
9
|
+
import { getContractArtifact } from "../utils/getContractArtifact";
|
10
|
+
import { knownModuleArtifacts } from "../utils/knownModuleArtifacts";
|
11
|
+
|
12
|
+
export async function configToModules<config extends World>(
|
13
|
+
config: config,
|
14
|
+
forgeOutDir: string,
|
15
|
+
): Promise<readonly Module[]> {
|
16
|
+
// this expects a namespaced table name when used with `resolveTableId`
|
17
|
+
const resolveContext = {
|
18
|
+
tableIds: Object.fromEntries(
|
19
|
+
Object.entries(config.tables).map(([tableName, table]) => [tableName, hexToBytes(table.tableId)]),
|
20
|
+
),
|
21
|
+
};
|
22
|
+
|
23
|
+
const modules = await Promise.all(
|
24
|
+
config.modules.map(async (mod): Promise<Module> => {
|
25
|
+
let artifactPath = mod.artifactPath;
|
26
|
+
|
27
|
+
// Backwards compatibility
|
28
|
+
// TODO: move this up a level so we don't need `forgeOutDir` in here?
|
29
|
+
if (!artifactPath) {
|
30
|
+
if (mod.name) {
|
31
|
+
artifactPath =
|
32
|
+
knownModuleArtifacts[mod.name as keyof typeof knownModuleArtifacts] ??
|
33
|
+
path.join(forgeOutDir, `${mod.name}.sol`, `${mod.name}.json`);
|
34
|
+
console.warn(
|
35
|
+
[
|
36
|
+
"",
|
37
|
+
`⚠️ Your \`mud.config.ts\` is using a module with a \`name\`, but this option is deprecated.`,
|
38
|
+
"",
|
39
|
+
"To resolve this, you can replace this:",
|
40
|
+
"",
|
41
|
+
` name: ${JSON.stringify(mod.name)}`,
|
42
|
+
"",
|
43
|
+
"with this:",
|
44
|
+
"",
|
45
|
+
` artifactPath: ${JSON.stringify(artifactPath)}`,
|
46
|
+
"",
|
47
|
+
].join("\n"),
|
48
|
+
);
|
49
|
+
} else {
|
50
|
+
throw new Error("No `artifactPath` provided for module.");
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
const name = path.basename(artifactPath, ".json");
|
55
|
+
const artifact = await getContractArtifact({ artifactPath });
|
56
|
+
|
57
|
+
// TODO: replace args with something more strongly typed
|
58
|
+
const installArgs = mod.args
|
59
|
+
.map((arg) => resolveWithContext(arg, resolveContext))
|
60
|
+
.map((arg) => {
|
61
|
+
const value = arg.value instanceof Uint8Array ? bytesToHex(arg.value) : arg.value;
|
62
|
+
return encodeField(arg.type as SchemaAbiType, value as SchemaAbiTypeToPrimitiveType<SchemaAbiType>);
|
63
|
+
});
|
64
|
+
|
65
|
+
if (installArgs.length > 1) {
|
66
|
+
throw new Error(`${name} module should only have 0-1 args, but had ${installArgs.length} args.`);
|
67
|
+
}
|
68
|
+
|
69
|
+
return {
|
70
|
+
name,
|
71
|
+
installAsRoot: mod.root,
|
72
|
+
installData: installArgs.length === 0 ? "0x" : installArgs[0],
|
73
|
+
prepareDeploy: createPrepareDeploy(artifact.bytecode, artifact.placeholders),
|
74
|
+
deployedBytecodeSize: artifact.deployedBytecodeSize,
|
75
|
+
abi: artifact.abi,
|
76
|
+
};
|
77
|
+
}),
|
78
|
+
);
|
79
|
+
|
80
|
+
return modules;
|
81
|
+
}
|
package/src/deploy/deploy.ts
CHANGED
@@ -2,7 +2,7 @@ import { Account, Address, Chain, Client, Hex, Transport } from "viem";
|
|
2
2
|
import { ensureDeployer } from "./ensureDeployer";
|
3
3
|
import { deployWorld } from "./deployWorld";
|
4
4
|
import { ensureTables } from "./ensureTables";
|
5
|
-
import { Config, ConfigInput, WorldDeploy, supportedStoreVersions, supportedWorldVersions } from "./common";
|
5
|
+
import { Config, ConfigInput, Module, WorldDeploy, supportedStoreVersions, supportedWorldVersions } from "./common";
|
6
6
|
import { ensureSystems } from "./ensureSystems";
|
7
7
|
import { waitForTransactionReceipt } from "viem/actions";
|
8
8
|
import { getWorldDeploy } from "./getWorldDeploy";
|
@@ -19,6 +19,7 @@ import { ensureWorldFactory } from "./ensureWorldFactory";
|
|
19
19
|
type DeployOptions<configInput extends ConfigInput> = {
|
20
20
|
client: Client<Transport, Chain | undefined, Account>;
|
21
21
|
config: Config<configInput>;
|
22
|
+
modules?: readonly Module[];
|
22
23
|
salt?: Hex;
|
23
24
|
worldAddress?: Address;
|
24
25
|
/**
|
@@ -40,6 +41,7 @@ type DeployOptions<configInput extends ConfigInput> = {
|
|
40
41
|
export async function deploy<configInput extends ConfigInput>({
|
41
42
|
client,
|
42
43
|
config,
|
44
|
+
modules = [],
|
43
45
|
salt,
|
44
46
|
worldAddress: existingWorldAddress,
|
45
47
|
deployerAddress: initialDeployerAddress,
|
@@ -66,7 +68,7 @@ export async function deploy<configInput extends ConfigInput>({
|
|
66
68
|
deployedBytecodeSize: system.deployedBytecodeSize,
|
67
69
|
label: `${resourceToLabel(system)} system`,
|
68
70
|
})),
|
69
|
-
...
|
71
|
+
...modules.map((mod) => ({
|
70
72
|
bytecode: mod.prepareDeploy(deployerAddress, config.libraries).bytecode,
|
71
73
|
deployedBytecodeSize: mod.deployedBytecodeSize,
|
72
74
|
label: `${mod.name} module`,
|
@@ -118,7 +120,7 @@ export async function deploy<configInput extends ConfigInput>({
|
|
118
120
|
deployerAddress,
|
119
121
|
libraries: config.libraries,
|
120
122
|
worldDeploy,
|
121
|
-
modules
|
123
|
+
modules,
|
122
124
|
});
|
123
125
|
|
124
126
|
const txs = [...tableTxs, ...systemTxs, ...functionTxs, ...moduleTxs];
|
@@ -38,12 +38,13 @@ export async function ensureModules({
|
|
38
38
|
pRetry(
|
39
39
|
async () => {
|
40
40
|
try {
|
41
|
+
const abi = [...worldAbi, ...mod.abi];
|
41
42
|
const moduleAddress = mod.prepareDeploy(deployerAddress, libraries).address;
|
42
43
|
return mod.installAsRoot
|
43
44
|
? await writeContract(client, {
|
44
45
|
chain: client.chain ?? null,
|
45
46
|
address: worldDeploy.address,
|
46
|
-
abi
|
47
|
+
abi,
|
47
48
|
// TODO: replace with batchCall (https://github.com/latticexyz/mud/issues/1645)
|
48
49
|
functionName: "installRootModule",
|
49
50
|
args: [moduleAddress, mod.installData],
|
@@ -51,7 +52,7 @@ export async function ensureModules({
|
|
51
52
|
: await writeContract(client, {
|
52
53
|
chain: client.chain ?? null,
|
53
54
|
address: worldDeploy.address,
|
54
|
-
abi
|
55
|
+
abi,
|
55
56
|
// TODO: replace with batchCall (https://github.com/latticexyz/mud/issues/1645)
|
56
57
|
functionName: "installModule",
|
57
58
|
args: [moduleAddress, mod.installData],
|
@@ -1,11 +1,9 @@
|
|
1
|
-
import { Client,
|
1
|
+
import { Client, parseAbiItem } from "viem";
|
2
2
|
import { WorldDeploy, WorldFunction, worldTables } from "./common";
|
3
3
|
import { debug } from "./debug";
|
4
4
|
import { storeSetRecordEvent } from "@latticexyz/store";
|
5
5
|
import { getLogs } from "viem/actions";
|
6
|
-
import { decodeValueArgs } from "@latticexyz/protocol-parser/internal";
|
7
|
-
import { getTableValue } from "./getTableValue";
|
8
|
-
import { hexToResource } from "@latticexyz/common";
|
6
|
+
import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser/internal";
|
9
7
|
|
10
8
|
export async function getFunctions({
|
11
9
|
client,
|
@@ -15,44 +13,52 @@ export async function getFunctions({
|
|
15
13
|
readonly worldDeploy: WorldDeploy;
|
16
14
|
}): Promise<readonly WorldFunction[]> {
|
17
15
|
// This assumes we only use `FunctionSelectors._set(...)`, which is true as of this writing.
|
18
|
-
debug("looking up function
|
19
|
-
const
|
16
|
+
debug("looking up function selectors for", worldDeploy.address);
|
17
|
+
const selectorLogs = await getLogs(client, {
|
20
18
|
strict: true,
|
21
19
|
fromBlock: worldDeploy.deployBlock,
|
22
20
|
toBlock: worldDeploy.stateBlock,
|
23
21
|
address: worldDeploy.address,
|
24
22
|
event: parseAbiItem(storeSetRecordEvent),
|
25
|
-
args: { tableId: worldTables.
|
23
|
+
args: { tableId: worldTables.world_FunctionSelectors.tableId },
|
24
|
+
});
|
25
|
+
|
26
|
+
const selectors = selectorLogs.map((log) => {
|
27
|
+
return {
|
28
|
+
...decodeValueArgs(worldTables.world_FunctionSelectors.valueSchema, log.args),
|
29
|
+
...decodeKey(worldTables.world_FunctionSelectors.keySchema, log.args.keyTuple),
|
30
|
+
};
|
26
31
|
});
|
32
|
+
debug("found", selectors.length, "function selectors for", worldDeploy.address);
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
|
34
|
+
// This assumes we only use `FunctionSignatures._set(...)`, which is true as of this writing.
|
35
|
+
debug("looking up function signatures for", worldDeploy.address);
|
36
|
+
const signatureLogs = await getLogs(client, {
|
37
|
+
strict: true,
|
38
|
+
fromBlock: worldDeploy.deployBlock,
|
39
|
+
toBlock: worldDeploy.stateBlock,
|
40
|
+
address: worldDeploy.address,
|
41
|
+
event: parseAbiItem(storeSetRecordEvent),
|
42
|
+
args: { tableId: worldTables.world_FunctionSignatures.tableId },
|
31
43
|
});
|
32
|
-
debug("found", signatures.length, "function signatures for", worldDeploy.address);
|
33
44
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
worldDeploy,
|
41
|
-
table: worldTables.world_FunctionSelectors,
|
42
|
-
key: { worldFunctionSelector: selector },
|
43
|
-
});
|
44
|
-
const { namespace, name } = hexToResource(systemId);
|
45
|
-
// TODO: find away around undoing contract logic (https://github.com/latticexyz/mud/issues/1708)
|
46
|
-
const systemFunctionSignature = namespace === "" ? signature : signature.replace(`${namespace}_${name}_`, "");
|
47
|
-
return {
|
48
|
-
signature,
|
49
|
-
selector,
|
50
|
-
systemId,
|
51
|
-
systemFunctionSignature,
|
52
|
-
systemFunctionSelector,
|
53
|
-
};
|
45
|
+
const selectorToSignature = Object.fromEntries(
|
46
|
+
signatureLogs.map((log) => {
|
47
|
+
return [
|
48
|
+
decodeKey(worldTables.world_FunctionSignatures.keySchema, log.args.keyTuple).functionSelector,
|
49
|
+
decodeValueArgs(worldTables.world_FunctionSignatures.valueSchema, log.args).functionSignature,
|
50
|
+
];
|
54
51
|
}),
|
55
52
|
);
|
53
|
+
debug("found", signatureLogs.length, "function signatures for", worldDeploy.address);
|
54
|
+
|
55
|
+
const functions = selectors.map(({ worldFunctionSelector, systemFunctionSelector, systemId }) => ({
|
56
|
+
selector: worldFunctionSelector,
|
57
|
+
signature: selectorToSignature[worldFunctionSelector],
|
58
|
+
systemFunctionSelector,
|
59
|
+
systemFunctionSignature: selectorToSignature[systemFunctionSelector],
|
60
|
+
systemId,
|
61
|
+
}));
|
56
62
|
|
57
63
|
return functions;
|
58
64
|
}
|
@@ -1,13 +1,9 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import { resolveWorldConfig } from "@latticexyz/world/internal";
|
3
|
-
import { Config, ConfigInput, Library,
|
3
|
+
import { Config, ConfigInput, Library, System, WorldFunction } from "./common";
|
4
4
|
import { resourceToHex } from "@latticexyz/common";
|
5
|
-
import {
|
6
|
-
import { encodeField } from "@latticexyz/protocol-parser/internal";
|
7
|
-
import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal";
|
8
|
-
import { Hex, hexToBytes, bytesToHex, toFunctionSelector, toFunctionSignature } from "viem";
|
5
|
+
import { Hex, toFunctionSelector, toFunctionSignature } from "viem";
|
9
6
|
import { getExistingContracts } from "../utils/getExistingContracts";
|
10
|
-
import { defaultModuleContracts } from "../utils/defaultModuleContracts";
|
11
7
|
import { getContractData } from "../utils/getContractData";
|
12
8
|
import { configToTables } from "./configToTables";
|
13
9
|
import { groupBy } from "@latticexyz/common/utils";
|
@@ -100,49 +96,9 @@ export function resolveConfig<config extends ConfigInput>({
|
|
100
96
|
);
|
101
97
|
}
|
102
98
|
|
103
|
-
// ugh (https://github.com/latticexyz/mud/issues/1668)
|
104
|
-
const resolveContext = {
|
105
|
-
tableIds: Object.fromEntries(
|
106
|
-
Object.entries(config.tables).map(([tableName, table]) => [
|
107
|
-
tableName,
|
108
|
-
hexToBytes(
|
109
|
-
resourceToHex({
|
110
|
-
type: table.offchainOnly ? "offchainTable" : "table",
|
111
|
-
namespace: config.namespace,
|
112
|
-
name: table.name,
|
113
|
-
}),
|
114
|
-
),
|
115
|
-
]),
|
116
|
-
),
|
117
|
-
};
|
118
|
-
|
119
|
-
const modules = config.modules.map((mod): Module => {
|
120
|
-
const contractData =
|
121
|
-
defaultModuleContracts.find((defaultMod) => defaultMod.name === mod.name) ??
|
122
|
-
getContractData(`${mod.name}.sol`, mod.name, forgeOutDir);
|
123
|
-
const installArgs = mod.args
|
124
|
-
.map((arg) => resolveWithContext(arg, resolveContext))
|
125
|
-
.map((arg) => {
|
126
|
-
const value = arg.value instanceof Uint8Array ? bytesToHex(arg.value) : arg.value;
|
127
|
-
return encodeField(arg.type as SchemaAbiType, value as SchemaAbiTypeToPrimitiveType<SchemaAbiType>);
|
128
|
-
});
|
129
|
-
if (installArgs.length > 1) {
|
130
|
-
throw new Error(`${mod.name} module should only have 0-1 args, but had ${installArgs.length} args.`);
|
131
|
-
}
|
132
|
-
return {
|
133
|
-
name: mod.name,
|
134
|
-
installAsRoot: mod.root,
|
135
|
-
installData: installArgs.length === 0 ? "0x" : installArgs[0],
|
136
|
-
prepareDeploy: createPrepareDeploy(contractData.bytecode, contractData.placeholders),
|
137
|
-
deployedBytecodeSize: contractData.deployedBytecodeSize,
|
138
|
-
abi: contractData.abi,
|
139
|
-
};
|
140
|
-
});
|
141
|
-
|
142
99
|
return {
|
143
100
|
tables,
|
144
101
|
systems,
|
145
|
-
modules,
|
146
102
|
libraries,
|
147
103
|
};
|
148
104
|
}
|
package/src/runDeploy.ts
CHANGED
@@ -16,6 +16,7 @@ import { postDeploy } from "./utils/postDeploy";
|
|
16
16
|
import { WorldDeploy } from "./deploy/common";
|
17
17
|
import { build } from "./build";
|
18
18
|
import { kmsKeyToAccount } from "@latticexyz/common/kms";
|
19
|
+
import { configToModules } from "./deploy/configToModules";
|
19
20
|
|
20
21
|
export const deployOptions = {
|
21
22
|
configPath: { type: "string", desc: "Path to the MUD config file" },
|
@@ -85,6 +86,7 @@ export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
|
|
85
86
|
}
|
86
87
|
|
87
88
|
const resolvedConfig = resolveConfig({ config, forgeSourceDir: srcDir, forgeOutDir: outDir });
|
89
|
+
const modules = await configToModules(configV2, outDir);
|
88
90
|
|
89
91
|
const account = await (async () => {
|
90
92
|
if (opts.kms) {
|
@@ -131,6 +133,7 @@ export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
|
|
131
133
|
worldAddress: opts.worldAddress as Hex | undefined,
|
132
134
|
client,
|
133
135
|
config: resolvedConfig,
|
136
|
+
modules,
|
134
137
|
withWorldProxy: configV2.deploy.upgradeableWorldImplementation,
|
135
138
|
});
|
136
139
|
if (opts.worldAddress == null || opts.alwaysRunPostDeploy) {
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { Abi, Hex, isHex, size } from "viem";
|
2
|
+
import { LibraryPlaceholder } from "../deploy/common";
|
3
|
+
import { findPlaceholders } from "./findPlaceholders";
|
4
|
+
import { z } from "zod";
|
5
|
+
import { Abi as abiSchema } from "abitype/zod";
|
6
|
+
|
7
|
+
export type GetContractArtifactOptions = {
|
8
|
+
/**
|
9
|
+
* Import path to contract's forge/solc JSON artifact with the contract's compiled bytecode.
|
10
|
+
*
|
11
|
+
* This path is resolved using node's contract resolution, so this supports both relative file paths (`../path/to/MyModule.json`) as well as JS import paths
|
12
|
+
* (`@latticexyz/world-contracts/out/CallWithSignatureModule.sol/CallWithSignatureModule.json`).
|
13
|
+
*/
|
14
|
+
artifactPath: string;
|
15
|
+
};
|
16
|
+
|
17
|
+
export type GetContractArtifactResult = {
|
18
|
+
bytecode: Hex;
|
19
|
+
placeholders: readonly LibraryPlaceholder[];
|
20
|
+
abi: Abi;
|
21
|
+
deployedBytecodeSize: number;
|
22
|
+
};
|
23
|
+
|
24
|
+
const bytecodeSchema = z.object({
|
25
|
+
object: z.string().refine(isHex),
|
26
|
+
linkReferences: z.record(
|
27
|
+
z.record(
|
28
|
+
z.array(
|
29
|
+
z.object({
|
30
|
+
start: z.number(),
|
31
|
+
length: z.number(),
|
32
|
+
}),
|
33
|
+
),
|
34
|
+
),
|
35
|
+
),
|
36
|
+
});
|
37
|
+
|
38
|
+
const artifactSchema = z.object({
|
39
|
+
bytecode: bytecodeSchema,
|
40
|
+
deployedBytecode: bytecodeSchema,
|
41
|
+
abi: abiSchema,
|
42
|
+
});
|
43
|
+
|
44
|
+
export async function getContractArtifact({
|
45
|
+
artifactPath,
|
46
|
+
}: GetContractArtifactOptions): Promise<GetContractArtifactResult> {
|
47
|
+
let importedArtifact;
|
48
|
+
try {
|
49
|
+
importedArtifact = (
|
50
|
+
await import(artifactPath, {
|
51
|
+
with: { type: "json" },
|
52
|
+
// `with` is the new approach, but `assert` is kept for backwards-compatibility with Node 18
|
53
|
+
assert: { type: "json" },
|
54
|
+
})
|
55
|
+
).default;
|
56
|
+
} catch (error) {
|
57
|
+
console.error();
|
58
|
+
console.error("Could not import contract artifact at", artifactPath);
|
59
|
+
console.error();
|
60
|
+
throw error;
|
61
|
+
}
|
62
|
+
|
63
|
+
// TODO: improve errors or replace with arktype?
|
64
|
+
const artifact = artifactSchema.parse(importedArtifact);
|
65
|
+
const placeholders = findPlaceholders(artifact.bytecode.linkReferences);
|
66
|
+
|
67
|
+
return {
|
68
|
+
abi: artifact.abi,
|
69
|
+
bytecode: artifact.bytecode.object,
|
70
|
+
placeholders,
|
71
|
+
deployedBytecodeSize: size(artifact.deployedBytecode.object),
|
72
|
+
};
|
73
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/** @deprecated Please don't add to this list! These are kept for backwards compatibility and assumes the downstream project has this module installed as a dependency. */
|
2
|
+
export const knownModuleArtifacts = {
|
3
|
+
KeysWithValueModule: "@latticexyz/world-modules/out/KeysWithValueModule.sol/KeysWithValueModule.json",
|
4
|
+
KeysInTableModule: "@latticexyz/world-modules/out/KeysInTableModule.sol/KeysInTableModule.json",
|
5
|
+
UniqueEntityModule: "@latticexyz/world-modules/out/UniqueEntityModule.sol/UniqueEntityModule.json",
|
6
|
+
Unstable_CallWithSignatureModule:
|
7
|
+
"@latticexyz/world-modules/out/Unstable_CallWithSignatureModule.sol/Unstable_CallWithSignatureModule.json",
|
8
|
+
};
|
package/src/verify.ts
CHANGED
@@ -5,7 +5,7 @@ import PQueue from "p-queue";
|
|
5
5
|
import { getWorldProxyFactoryContracts } from "./deploy/getWorldProxyFactoryContracts";
|
6
6
|
import { getDeployer } from "./deploy/getDeployer";
|
7
7
|
import { MUDError } from "@latticexyz/common/errors";
|
8
|
-
import { salt } from "./deploy/common";
|
8
|
+
import { Module, salt } from "./deploy/common";
|
9
9
|
import { getStorageAt } from "viem/actions";
|
10
10
|
import { execa } from "execa";
|
11
11
|
|
@@ -15,7 +15,7 @@ type VerifyOptions = {
|
|
15
15
|
verifier: string;
|
16
16
|
verifierUrl?: string;
|
17
17
|
systems: { name: string; bytecode: Hex }[];
|
18
|
-
modules:
|
18
|
+
modules: readonly Module[];
|
19
19
|
worldAddress: Hex;
|
20
20
|
/**
|
21
21
|
* Address of determinstic deployment proxy: https://github.com/Arachnid/deterministic-deployment-proxy
|
@@ -39,7 +39,7 @@ export async function verify({
|
|
39
39
|
}: VerifyOptions): Promise<void> {
|
40
40
|
const deployerAddress = initialDeployerAddress ?? (await getDeployer(client));
|
41
41
|
if (!deployerAddress) {
|
42
|
-
throw new MUDError(
|
42
|
+
throw new MUDError("No deployer address provided or found.");
|
43
43
|
}
|
44
44
|
|
45
45
|
// If the proxy implementation storage slot is set on the World, the World was deployed as a proxy.
|
@@ -104,24 +104,22 @@ export async function verify({
|
|
104
104
|
),
|
105
105
|
);
|
106
106
|
|
107
|
-
modules.map(({ name,
|
108
|
-
|
107
|
+
modules.map(({ name, prepareDeploy }) => {
|
108
|
+
const { address } = prepareDeploy(deployerAddress, []);
|
109
|
+
return verifyQueue.add(() =>
|
109
110
|
verifyContract({
|
111
|
+
// TODO: figure out dir from artifactPath via import.meta.resolve?
|
110
112
|
cwd: "node_modules/@latticexyz/world-modules",
|
111
|
-
name
|
113
|
+
name,
|
112
114
|
rpc,
|
113
115
|
verifier,
|
114
116
|
verifierUrl,
|
115
|
-
address
|
116
|
-
from: deployerAddress,
|
117
|
-
bytecode: bytecode,
|
118
|
-
salt,
|
119
|
-
}),
|
117
|
+
address,
|
120
118
|
}).catch((error) => {
|
121
119
|
console.error(`Error verifying module contract ${name}:`, error);
|
122
120
|
}),
|
123
|
-
)
|
124
|
-
);
|
121
|
+
);
|
122
|
+
});
|
125
123
|
|
126
124
|
// If the world was deployed as a Proxy, verify the proxy and implementation.
|
127
125
|
if (usesProxy) {
|