diff --git a/.changeset/quick-lions-rest.md b/.changeset/quick-lions-rest.md new file mode 100644 index 0000000000..55fff3a6d3 --- /dev/null +++ b/.changeset/quick-lions-rest.md @@ -0,0 +1,10 @@ +--- +"@latticexyz/cli": patch +--- + +The key ID for deploying via KMS signer is now set via an `AWS_KMS_KEY_ID` environment variable to better align with Foundry tooling. To enable KMS signing with this environment variable, use the `--kms` flag. + +```diff +-mud deploy --awsKmsKeyId [key ID] ++AWS_KMS_KEY_ID=[key ID] mud deploy --kms +``` diff --git a/packages/cli/src/commands/dev-contracts.ts b/packages/cli/src/commands/dev-contracts.ts index a0b65ce1f7..ab8d655c7a 100644 --- a/packages/cli/src/commands/dev-contracts.ts +++ b/packages/cli/src/commands/dev-contracts.ts @@ -92,7 +92,7 @@ const commandModule: CommandModule; @@ -87,8 +87,14 @@ export async function runDeploy(opts: DeployOptions): Promise { const resolvedConfig = resolveConfig({ config, forgeSourceDir: srcDir, forgeOutDir: outDir }); const account = await (async () => { - if (opts.awsKmsKeyId) { - const keyId = opts.awsKmsKeyId ?? process.env.AWS_KMS_KEY_ID; + if (opts.kms) { + const keyId = process.env.AWS_KMS_KEY_ID; + if (!keyId) { + throw new MUDError( + "Missing `AWS_KMS_KEY_ID` environment variable. This is required when using with `--kms` option.", + ); + } + return await kmsKeyToAccount({ keyId }); } else { const privateKey = process.env.PRIVATE_KEY; diff --git a/packages/common/src/account/kms/getAddressFromKms.ts b/packages/common/src/account/kms/getAddressFromKms.ts index cd8836bd49..181d282d15 100644 --- a/packages/common/src/account/kms/getAddressFromKms.ts +++ b/packages/common/src/account/kms/getAddressFromKms.ts @@ -1,6 +1,6 @@ import { Address, toHex } from "viem"; import { publicKeyToAddress } from "viem/utils"; -import { KMSClient, SignCommandInput } from "@aws-sdk/client-kms"; +import { GetPublicKeyCommandInput, KMSClient } from "@aws-sdk/client-kms"; import { getPublicKey } from "./getPublicKey"; // @ts-expect-error Could not find a declaration file for module 'asn1.js'. import asn1 from "asn1.js"; @@ -25,7 +25,7 @@ export async function getAddressFromKms({ keyId, client, }: { - keyId: SignCommandInput["KeyId"]; + keyId: GetPublicKeyCommandInput["KeyId"]; client: KMSClient; }): Promise
{ const KMSKey = await getPublicKey({ keyId, client });