Skip to content

Conversation

@jakehobbs
Copy link
Contributor

@jakehobbs jakehobbs commented Dec 15, 2025

Pull Request Checklist


PR-Codex overview

This PR enhances the handling of factory data for deriving account addresses in the smart-accounts package. It introduces new functions to retrieve addresses from factory data, improving the prediction mechanism and ensuring fallback to RPC when necessary.

Detailed summary

  • Added getLightAccountAddressFromFactoryData and getMultiOwnerLightAccountAddressFromFactoryData for address prediction.
  • Updated toLightAccount and toMultiOwnerLightAccount functions to utilize new factory data methods.
  • Enhanced test cases to verify address derivation using factory data.
  • Refactored address prediction logic to fallback to RPC for non-default factories.
  • Introduced new utility functions for decoding factory data and generating addresses.

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

@github-actions
Copy link

github-actions bot commented Dec 15, 2025

🌿 Documentation Preview

Name Status Preview Updated (UTC)
Alchemy Docs ✅ Ready 🔗 Visit Preview Dec 16, 2025, 12:24 AM

@github-actions github-actions bot temporarily deployed to docs-preview December 15, 2025 21:55 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview December 15, 2025 21:55 Inactive
@vercel
Copy link

vercel bot commented Dec 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
aa-sdk-ui-demo Ignored Ignored Preview Dec 16, 2025 0:22am

@github-actions github-actions bot temporarily deployed to docs-preview December 15, 2025 22:04 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview December 15, 2025 22:04 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview December 15, 2025 22:09 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview December 15, 2025 22:10 Inactive
@jakehobbs jakehobbs marked this pull request as ready for review December 15, 2025 22:15
Copilot AI review requested due to automatic review settings December 15, 2025 22:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances smart account address derivation by introducing the ability to compute account addresses from factory data when the account address is not explicitly provided. The key change is adding a getSenderFromFactoryData utility function that calls the EntryPoint contract's getSenderAddress method to derive the counterfactual address.

Key Changes:

  • Added getSenderFromFactoryData utility function to derive smart account addresses from factory data by calling EntryPoint's getSenderAddress
  • Updated account creation functions (toLightAccount, toMultiOwnerLightAccount, toModularAccountV2, toMultiOwnerModularAccountV1) to use this new utility when factory data is provided without an account address
  • Added test coverage for address derivation using factory data across all affected account types

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/smart-accounts/src/utils.ts Added getSenderFromFactoryData function to derive addresses from factory data via EntryPoint
packages/smart-accounts/src/ma-v2/accounts/account.ts Updated toModularAccountV2 to derive address from factory data when provided without account address
packages/smart-accounts/src/ma-v2/accounts/account.test.ts Added test to verify address derivation from factory data
packages/smart-accounts/src/ma-v1/accounts/multi-owner-account.ts Updated toMultiOwnerModularAccountV1 to use factory data for address derivation
packages/smart-accounts/src/ma-v1/accounts/multi-owner-account.test.ts Added test and updated test helper to support factory data parameters
packages/smart-accounts/src/light-account/accounts/multi-owner-account.ts Updated toMultiOwnerLightAccount to derive address from factory data
packages/smart-accounts/src/light-account/accounts/multi-owner-account.test.ts Added test and updated test helper for factory data address derivation
packages/smart-accounts/src/light-account/accounts/account.ts Updated toLightAccount to use factory data for address computation
packages/smart-accounts/src/light-account/accounts/account.test.ts Added test and updated helper to verify factory data address derivation
packages/smart-accounts/src/ma-v2/utils/account.ts Minor import formatting change
docs-site Updated subproject commit reference

Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

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

This makes sense, but we can technically be a bit stricter for the cases where using getSenderAddress is required:

  • If the factory address is still the known, default address, then we should prioritize ABI-decoding the factoryData and doing local counterfactual computation, because that lets us skip the async call.

This does make it a bit harder to test, but I think it's technically a better model of when the eth_call is really necessary.

type Hex,
} from "viem";
import type { SmartAccount } from "viem/account-abstraction";
import { type SmartAccount } from "viem/account-abstraction";
Copy link
Contributor

Choose a reason for hiding this comment

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

iirc, having only type imports within a regular import block caused issues for React Native

Copy link
Contributor Author

@jakehobbs jakehobbs Dec 15, 2025

Choose a reason for hiding this comment

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

thx, will change.

the issue w/ RN wasn't necessarily due to importing anything like this though. it was just b/c importing typebox at runtime was breaking things. viem works fine.

@github-actions github-actions bot temporarily deployed to docs-preview December 16, 2025 00:22 Inactive
@github-actions github-actions bot temporarily deployed to docs-preview December 16, 2025 00:22 Inactive
@jakehobbs jakehobbs requested a review from adamegyed December 16, 2025 00:34
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