Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): do not require PRIVATE_KEY if using KMS #2765

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

yonadaa
Copy link
Contributor

@yonadaa yonadaa commented Apr 29, 2024

No description provided.

@yonadaa yonadaa requested review from alvrs and holic as code owners April 29, 2024 17:53
Copy link

changeset-bot bot commented Apr 29, 2024

🦋 Changeset detected

Latest commit: b8b70d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@latticexyz/cli Patch
mock-game-contracts Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/dev-tools Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/protocol-parser Patch
@latticexyz/query Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
@latticexyz/services Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/utils Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yonadaa yonadaa changed the title fix(cli): do not require private_key if kms fix(cli): do not require PRIVATE_KEY if using KMS Apr 29, 2024
@@ -85,7 +85,7 @@ export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
}

const privateKey = process.env.PRIVATE_KEY as Hex;
if (!privateKey) {
if (!opts.awsKmsKeyId && !privateKey) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this PK block down under resolvedConfig so its a bit more localized with the KMS stuff?

and could potentially wrap it in a self invoking function like

const account = keyId ? await kmsKeyToAccount({ keyId }) : (() => {
  const privateKey = process.env.PRIVATE_KEY as Hex;
  if (!privateKey) {
    throw new MUDError(
      `Missing PRIVATE_KEY environment variable.
Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env'
in your contracts directory to use the default anvil private key.`,
    );
  }
  return privateKeyToAccount(privateKey);
})();

or maybe pull that out into something like envPrivateKeyToAccount()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapped it all in a self-invoking function! I like that the two environment variables are only used there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and one we might be able to ditch in #2760 ?

@holic holic merged commit 3031868 into main Apr 29, 2024
12 checks passed
@holic holic deleted the yonadaaa/private-key-warning branch April 29, 2024 18:11
dhvanipa pushed a commit to tenetxyz/mud that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants