Skip to content

feat: adds webauthn client tests #1563

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

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft

feat: adds webauthn client tests #1563

wants to merge 26 commits into from

Conversation

linnall
Copy link
Collaborator

@linnall linnall commented Apr 24, 2025

Pull Request Checklist


PR-Codex overview

This PR introduces support for a new webauthn mode in the Modular Account V2 functionality, allowing accounts to be created and managed without a signer. It includes a new gas estimator and updates various types and functions to accommodate this change.

Detailed summary

  • Updated CreateModularAccountV2Params to include CreateModularAccountV2ParamsNoSigner.
  • Modified return types in createModularAccountV2 to support ModularAccountV2NoSigner.
  • Added webauthnGasEstimator function for estimating gas usage.
  • Created documentation for webauthnGasEstimator.
  • Enhanced createModularAccountV2Client to handle webauthn mode.
  • Introduced ModularAccountV2NoSigner type for accounts without a signer.
  • Updated various functions to handle parameters specific to webauthn.
  • Added tests for signing and validating messages with WebAuthn accounts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Apr 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aa-sdk-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 3:35pm
aa-sdk-ui-demo ❌ Failed (Inspect) May 22, 2025 3:35pm

Copy link

graphite-app bot commented Apr 24, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link

github-actions bot commented Apr 24, 2025

🌿 Documentation Preview

Name Status Preview Updated (UTC)
Alchemy Docs ✅ Ready 🔗 Visit Preview May 22, 2025, 3:31 PM

@github-actions github-actions bot temporarily deployed to docs-preview April 24, 2025 22:19 Inactive
// connect session key
let sessionKeyClient = await createModularAccountV2Client({
chain: instance.chain,
signer: webAuthnSigningMethodsSessionKey,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should be passing in instance of SmartAccountSigner here

name: "backUp",
});

const webAuthnSigningMethods: SmartAccountSigner = new WebAuthnSigningMethods(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I am mistakenly treating this like an instance of SmartAccountSigner when this is a standalone collection of webauthn signing methods, so it would get access to the WebAuthnCredentials via the account

Copy link
Collaborator

Choose a reason for hiding this comment

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

I left comments in the spec about this. It's not a smart account signer, it's what's used to create the various sign* methods on the account itself. the account doesn't take a signer as input anymore, and just takes in the credential

@github-actions github-actions bot temporarily deployed to docs-preview April 29, 2025 19:10 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview April 29, 2025 21:24 Inactive
@github-actions github-actions bot had a problem deploying to docs-preview May 9, 2025 21:43 Failure
@github-actions github-actions bot temporarily deployed to docs-preview May 11, 2025 02:41 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 12, 2025 20:11 Inactive
@linnall linnall force-pushed the linna/webauth-tests branch from 36cd477 to 7549458 Compare May 12, 2025 20:21
@github-actions github-actions bot temporarily deployed to docs-preview May 12, 2025 20:21 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 12, 2025 20:28 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview May 13, 2025 00:03 Inactive
@linnall linnall force-pushed the linna/webauth-tests branch from 3f608b1 to aec0234 Compare May 22, 2025 15:29
@github-actions github-actions bot temporarily deployed to docs-preview May 22, 2025 15:29 Inactive
@@ -94,6 +102,152 @@ describe("MA v2 Tests", async () => {
accounts.unfundedAccountOwner,
);

const publicKey = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ [eslint] <@typescript-eslint/no-unused-vars> reported by reviewdog 🐶
'publicKey' is assigned a value but never used.

* ```
*
* @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function
* @returns {Function} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
* @returns {Function} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
* @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.

Comment on lines +79 to +87
console.log({ chainHas7212 });

console.log("...");
console.log(BigInt(typeof pvg === "string" ? BigInt(pvg) : pvg));
console.log(chainHas7212 ? 10000n : 300000n);
console.log(
BigInt(typeof pvg === "string" ? BigInt(pvg) : pvg) +
(chainHas7212 ? 10000n : 300000n)
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
console.log({ chainHas7212 });
console.log("...");
console.log(BigInt(typeof pvg === "string" ? BigInt(pvg) : pvg));
console.log(chainHas7212 ? 10000n : 300000n);
console.log(
BigInt(typeof pvg === "string" ? BigInt(pvg) : pvg) +
(chainHas7212 ? 10000n : 300000n)
);

@@ -70,9 +73,24 @@ export type ModularAccountV2<
encodeCallData: (callData: Hex) => Promise<Hex>;
};

export type ModularAccountV2NoSigner = SmartContractAccount<
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export type ModularAccountV2NoSigner = SmartContractAccount<
export type WebauthnModularAccountV2 = SmartContractAccount<

@@ -54,13 +57,36 @@ export type CreateModularAccountV2Params<
}
);

// currently the only ModularAccountV2 mode that doesn't require a signer is "webauthn"
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we just call it webauthn mav2?

"transport" | "chain" | "accountAddress"
> & {
mode: "webauthn";
params: ToWebAuthnAccountParameters;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what are these types? can we flatten them rather than having params here?

@@ -41,6 +52,15 @@ export type CreateModularAccountV2ClientParams<
"transport" | "account" | "chain"
>;

export type CreateModularAccountV2ClientParamsNoSigner<
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@@ -50,7 +70,7 @@ export type CreateModularAccountV2AlchemyClientParams<
"transport"
> &
Omit<
AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>,
AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>, // TO DO: split this type so that it doesn't require a signer
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this LightAccount?

Comment on lines +101 to +104
args: CreateModularAccountV2ClientParamsNoSigner<TTransport, TChain> &
NotType<TTransport, AlchemyTransport> & {
params: ToWebAuthnAccountParameters;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does this need the params: intersection? shouldn't that be part of CreateModularAccountV2ClientParamsNoSigner?

);
}

console.log("\n\n\n\n\n a \n\n\n\n\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
console.log("\n\n\n\n\n a \n\n\n\n\n");

Copy link
Collaborator

Choose a reason for hiding this comment

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

ni can we call this signingMethods.ts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or functions, w/e we export from the file

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.

4 participants