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

refactor(common,cli): kms deployer gets keyId from environment #2760

Merged
merged 20 commits into from
Apr 29, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix: throw if no keyId
  • Loading branch information
yonadaa committed Apr 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3ef20b9237baff117a168004dfe63b44a04c093f
7 changes: 6 additions & 1 deletion packages/common/src/account/kms/kmsKeyToAccount.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { LocalAccount, hashMessage, hashTypedData, keccak256, serializeTransacti
import { toAccount } from "viem/accounts";
import { signWithKms } from "./signWithKms";
import { getAddressFromKms } from "./getAddressFromKms";
import { MUDError } from "../../errors";

export type KmsKeyToAccountOptions = {
keyId?: string;
@@ -19,11 +20,15 @@ export type KmsAccount = LocalAccount<"aws-kms"> & {
* @returns A Local Account.
*/
export async function kmsKeyToAccount({
keyId = process.env.AWS_KMS_KEY_ID || "",
keyId = process.env.AWS_KMS_KEY_ID,
yonadaa marked this conversation as resolved.
Show resolved Hide resolved
client = new KMSClient(),
}: KmsKeyToAccountOptions = {}): Promise<KmsAccount> {
const address = await getAddressFromKms({ keyId, client });

if (!keyId) {
throw new MUDError("Missing AWS KMS Key ID");
}
yonadaa marked this conversation as resolved.
Show resolved Hide resolved

const account = toAccount({
address,
async signMessage({ message }) {
Loading