From 428ff972198425cb19d363c92eb49002accdc6a0 Mon Sep 17 00:00:00 2001 From: yonada Date: Mon, 29 Apr 2024 23:24:44 +0100 Subject: [PATCH] fix(cli): run postdeploy with aws flag when kms is enabled (#2766) Co-authored-by: Kevin Ingersoll --- .changeset/hip-chairs-fly.md | 14 ++++++++++++++ packages/cli/src/runDeploy.ts | 9 ++++++++- packages/cli/src/utils/postDeploy.ts | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .changeset/hip-chairs-fly.md diff --git a/.changeset/hip-chairs-fly.md b/.changeset/hip-chairs-fly.md new file mode 100644 index 0000000000..94428631af --- /dev/null +++ b/.changeset/hip-chairs-fly.md @@ -0,0 +1,14 @@ +--- +"@latticexyz/cli": patch +--- + +Fixed `mud deploy` to use the `forge script --aws` flag when executing `PostDeploy` with a KMS signer. + +Note that you may need to update your `PostDeploy.s.sol` script, with `vm.startBroadcast` receiving no arguments instead of reading a private key from the environment: + +```diff +-uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); +-vm.startBroadcast(deployerPrivateKey); + ++vm.startBroadcast(); +``` diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index 2363aa8e03..0f049b9f63 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -134,7 +134,14 @@ export async function runDeploy(opts: DeployOptions): Promise { withWorldProxy: configV2.deploy.upgradeableWorldImplementation, }); if (opts.worldAddress == null || opts.alwaysRunPostDeploy) { - await postDeploy(config.postDeployScript, worldDeploy.address, rpc, profile, opts.forgeScriptOptions); + await postDeploy( + config.postDeployScript, + worldDeploy.address, + rpc, + profile, + opts.forgeScriptOptions, + opts.awsKmsKeyId !== undefined, + ); } console.log(chalk.green("Deployment completed in", (Date.now() - startTime) / 1000, "seconds")); diff --git a/packages/cli/src/utils/postDeploy.ts b/packages/cli/src/utils/postDeploy.ts index 5e4fc41553..38aceee998 100644 --- a/packages/cli/src/utils/postDeploy.ts +++ b/packages/cli/src/utils/postDeploy.ts @@ -9,6 +9,7 @@ export async function postDeploy( rpc: string, profile: string | undefined, forgeOptions: string | undefined, + kms: boolean, ): Promise { // TODO: make this more robust as it is likely to fail for any args that have a space in them const userOptions = forgeOptions?.replaceAll("\\", "").split(" ") ?? []; @@ -31,6 +32,7 @@ export async function postDeploy( "--rpc-url", rpc, "-vvv", + kms ? "--aws" : "", ...userOptions, ], {