@latticexyz/cli 2.0.9-main-93690fdb → 2.0.9-main-428ff972
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-QQKDUG7N.js → commands-IFZWIGEE.js} +18 -18
- package/dist/commands-IFZWIGEE.js.map +1 -0
- package/dist/mud.js +1 -1
- package/package.json +12 -12
- package/src/commands/dev-contracts.ts +1 -1
- package/src/runDeploy.ts +34 -15
- package/src/utils/postDeploy.ts +2 -0
- package/dist/commands-QQKDUG7N.js.map +0 -1
package/src/runDeploy.ts
CHANGED
@@ -43,9 +43,9 @@ export const deployOptions = {
|
|
43
43
|
type: "string",
|
44
44
|
desc: "The deployment salt to use. Defaults to a random salt.",
|
45
45
|
},
|
46
|
-
|
47
|
-
type: "
|
48
|
-
desc: "
|
46
|
+
kms: {
|
47
|
+
type: "boolean",
|
48
|
+
desc: "Deploy the World with an AWS KMS key instead of local private key.",
|
49
49
|
},
|
50
50
|
} as const satisfies Record<string, Options>;
|
51
51
|
|
@@ -84,19 +84,31 @@ export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
|
|
84
84
|
await build({ config: configV2, srcDir, foundryProfile: profile });
|
85
85
|
}
|
86
86
|
|
87
|
-
const privateKey = process.env.PRIVATE_KEY as Hex;
|
88
|
-
if (!privateKey) {
|
89
|
-
throw new MUDError(
|
90
|
-
`Missing PRIVATE_KEY environment variable.
|
91
|
-
Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env'
|
92
|
-
in your contracts directory to use the default anvil private key.`,
|
93
|
-
);
|
94
|
-
}
|
95
|
-
|
96
87
|
const resolvedConfig = resolveConfig({ config, forgeSourceDir: srcDir, forgeOutDir: outDir });
|
97
88
|
|
98
|
-
const
|
99
|
-
|
89
|
+
const account = await (async () => {
|
90
|
+
if (opts.kms) {
|
91
|
+
const keyId = process.env.AWS_KMS_KEY_ID;
|
92
|
+
if (!keyId) {
|
93
|
+
throw new MUDError(
|
94
|
+
"Missing `AWS_KMS_KEY_ID` environment variable. This is required when using with `--kms` option.",
|
95
|
+
);
|
96
|
+
}
|
97
|
+
|
98
|
+
return await kmsKeyToAccount({ keyId });
|
99
|
+
} else {
|
100
|
+
const privateKey = process.env.PRIVATE_KEY;
|
101
|
+
if (!privateKey) {
|
102
|
+
throw new MUDError(
|
103
|
+
`Missing PRIVATE_KEY environment variable.
|
104
|
+
Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env'
|
105
|
+
in your contracts directory to use the default anvil private key.`,
|
106
|
+
);
|
107
|
+
}
|
108
|
+
|
109
|
+
return privateKeyToAccount(privateKey as Hex);
|
110
|
+
}
|
111
|
+
})();
|
100
112
|
|
101
113
|
const client = createWalletClient({
|
102
114
|
transport: http(rpc, {
|
@@ -122,7 +134,14 @@ in your contracts directory to use the default anvil private key.`,
|
|
122
134
|
withWorldProxy: configV2.deploy.upgradeableWorldImplementation,
|
123
135
|
});
|
124
136
|
if (opts.worldAddress == null || opts.alwaysRunPostDeploy) {
|
125
|
-
await postDeploy(
|
137
|
+
await postDeploy(
|
138
|
+
config.postDeployScript,
|
139
|
+
worldDeploy.address,
|
140
|
+
rpc,
|
141
|
+
profile,
|
142
|
+
opts.forgeScriptOptions,
|
143
|
+
opts.awsKmsKeyId !== undefined,
|
144
|
+
);
|
126
145
|
}
|
127
146
|
console.log(chalk.green("Deployment completed in", (Date.now() - startTime) / 1000, "seconds"));
|
128
147
|
|
package/src/utils/postDeploy.ts
CHANGED
@@ -9,6 +9,7 @@ export async function postDeploy(
|
|
9
9
|
rpc: string,
|
10
10
|
profile: string | undefined,
|
11
11
|
forgeOptions: string | undefined,
|
12
|
+
kms: boolean,
|
12
13
|
): Promise<void> {
|
13
14
|
// TODO: make this more robust as it is likely to fail for any args that have a space in them
|
14
15
|
const userOptions = forgeOptions?.replaceAll("\\", "").split(" ") ?? [];
|
@@ -31,6 +32,7 @@ export async function postDeploy(
|
|
31
32
|
"--rpc-url",
|
32
33
|
rpc,
|
33
34
|
"-vvv",
|
35
|
+
kms ? "--aws" : "",
|
34
36
|
...userOptions,
|
35
37
|
],
|
36
38
|
{
|