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

feat(cli): deploy with kms #2704

Merged
merged 56 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d43eb2f
feat(cli): deploy via kms
yonadaa Apr 18, 2024
bbf9819
rename file
yonadaa Apr 18, 2024
5a1f697
feat: it works
yonadaa Apr 19, 2024
6233816
chore: unused package
yonadaa Apr 19, 2024
76e2dca
feat: viem account
yonadaa Apr 19, 2024
16068a0
refactor: file
yonadaa Apr 19, 2024
621b5c2
refactor: move to common
yonadaa Apr 19, 2024
c7aacb3
refactor: address types
yonadaa Apr 19, 2024
e368be0
feat: signTransaction
yonadaa Apr 19, 2024
4dd5e85
chore: lockfile
yonadaa Apr 19, 2024
0bcc517
refactor: types
yonadaa Apr 19, 2024
808fd25
test: local testing
yonadaa Apr 19, 2024
ef738ad
refactor: signatureToHex
yonadaa Apr 19, 2024
3b1161c
refactor: types
yonadaa Apr 19, 2024
aeacfd9
refactor: compute public key
yonadaa Apr 19, 2024
874a9f4
refactor: custom arrayify util
yonadaa Apr 19, 2024
b784718
refactor: recovery param
yonadaa Apr 19, 2024
6b70a3d
refactor: rename variable
yonadaa Apr 19, 2024
16e4996
refactor: ethers dependency
yonadaa Apr 19, 2024
3f06929
refactor: package version
yonadaa Apr 19, 2024
c58feea
refactor: rename account
yonadaa Apr 19, 2024
a9405dd
refactor: filename
yonadaa Apr 22, 2024
bafcdb8
refactor: fromHex
yonadaa Apr 22, 2024
14b886a
test: attempt to run local kms
yonadaa Apr 22, 2024
ec0e3a3
hardcode endpoint
yonadaa Apr 22, 2024
4adf782
Revert "hardcode endpoint"
yonadaa Apr 22, 2024
a92a8a7
fix: env variable
yonadaa Apr 22, 2024
c73c834
test: beforeAll
yonadaa Apr 22, 2024
417b1bb
feat: optional dependencies
yonadaa Apr 22, 2024
8b7dbdc
refactor: remove ethers dependency
yonadaa Apr 22, 2024
6a87377
refactor: export, rename, move files
yonadaa Apr 22, 2024
1285129
Merge remote-tracking branch 'origin/main' into yonadaaa/deploy-kms
yonadaa Apr 22, 2024
9b278f2
feat(cli): KMS deployer
yonadaa Apr 22, 2024
c86d6ae
feat: use flag
yonadaa Apr 22, 2024
ed3919d
refactor: types
yonadaa Apr 22, 2024
605cfa7
refactor: get credentials from env
yonadaa Apr 23, 2024
cd41a7c
chore: cli doesnt need asn1
yonadaa Apr 23, 2024
2e0ae9f
refactor: region and endpoint from CLI
yonadaa Apr 23, 2024
59f2420
refactor: just keyid
yonadaa Apr 23, 2024
eb48a96
fix: output
yonadaa Apr 23, 2024
22fc7b7
refactor: no object
yonadaa Apr 23, 2024
bf0059d
refactor: cli option
yonadaa Apr 23, 2024
8b99b6d
fix: packages
yonadaa Apr 23, 2024
97d6764
refactor: rename option, env variable
yonadaa Apr 23, 2024
bd1f8d9
chore: install
yonadaa Apr 23, 2024
caa9e00
chore: tweak description
yonadaa Apr 23, 2024
8a8856e
chore: changeset
yonadaa Apr 23, 2024
bdcd332
docs: tweak description
yonadaa Apr 23, 2024
b0bc562
refactor: useProxy thing
yonadaa Apr 23, 2024
1c8fb71
Merge remote-tracking branch 'origin/main' into yonadaaa/kms-deployer
yonadaa Apr 24, 2024
581c04c
fix: dev-contracts
yonadaa Apr 24, 2024
233f197
chore: reset examples
yonadaa Apr 24, 2024
1a2ee2f
chore: delete unused files
yonadaa Apr 24, 2024
0b2e5f7
Merge remote-tracking branch 'origin/main' into yonadaaa/kms-deployer
yonadaa Apr 25, 2024
74ddd05
fix: import after merge
yonadaa Apr 25, 2024
a4ccd8f
Update .changeset/early-teachers-greet.md
holic Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/early-teachers-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/cli": patch
---

Added a `awsKmsKeyId` flag to `mud deploy` that deploys the world using an AWS KMS signer.
holic marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"test:ci": "pnpm run test"
},
"dependencies": {
"@aws-sdk/client-kms": "^3.556.0",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@improbable-eng/grpc-web": "^0.15.0",
Expand All @@ -45,6 +46,7 @@
"@latticexyz/utils": "workspace:*",
"@latticexyz/world": "workspace:*",
"@latticexyz/world-modules": "workspace:*",
"asn1.js": "^5.4.1",
"chalk": "^5.0.1",
"chokidar": "^3.5.3",
"debug": "^4.3.4",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/dev-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const commandModule: CommandModule<typeof devOptions, InferredOptionTypes<typeof
worldAddress,
srcDir,
salt: "0x",
awsKmsKeyId: undefined,
});
worldAddress = deploy.address;
// if there were changes while we were deploying, trigger it again
Expand Down
10 changes: 9 additions & 1 deletion packages/cli/src/runDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getChainId } from "viem/actions";
import { postDeploy } from "./utils/postDeploy";
import { WorldDeploy } from "./deploy/common";
import { build } from "./build";
import { kmsKeyToAccount } from "@latticexyz/common/kms";

export const deployOptions = {
configPath: { type: "string", desc: "Path to the MUD config file" },
Expand Down Expand Up @@ -42,6 +43,10 @@ export const deployOptions = {
type: "string",
desc: "The deployment salt to use. Defaults to a random salt.",
},
awsKmsKeyId: {
type: "string",
desc: "Optional AWS KMS key ID. If set, the World is deployed using a KMS signer instead of local private key.",
},
} as const satisfies Record<string, Options>;

export type DeployOptions = InferredOptionTypes<typeof deployOptions>;
Expand Down Expand Up @@ -90,6 +95,9 @@ in your contracts directory to use the default anvil private key.`,

const resolvedConfig = resolveConfig({ config, forgeSourceDir: srcDir, forgeOutDir: outDir });

const keyId = opts.awsKmsKeyId ?? process.env.AWS_KMS_KEY_ID;
const account = keyId ? await kmsKeyToAccount({ keyId }) : privateKeyToAccount(privateKey);

const client = createWalletClient({
transport: http(rpc, {
batch: opts.rpcBatch
Expand All @@ -99,7 +107,7 @@ in your contracts directory to use the default anvil private key.`,
}
: undefined,
}),
account: privateKeyToAccount(privateKey),
account,
});

console.log("Deploying from", client.account.address);
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/account/kms/kmsKeyToAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type KmsAccount = LocalAccount<"aws-kms"> & {
*
* @returns A Local Account.
*/

export async function kmsKeyToAccount({
keyId,
client = new KMSClient(),
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading