You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make getFactoryArgs() throw a clear BaseError when factoryData is missing.
Add regression coverage for the provided and missing factoryData paths.
Why
When factoryData is undefined, returning { factory, factoryData: undefined } can silently produce no init code for an undeployed account and defer the failure to bundler/EntryPoint simulation. The SDK cannot safely derive Coinbase Smart Account factory data from only a single owner and owner index, so failing early is safer.
Testing
git diff --check
corepack yarn workspace @base-org/account test createSmartAccount could not run because the local checkout has no Yarn state/install (Couldn't find the node_modules state file).
Reviewed the fix — the analysis in #377 is correct and failing early is the right call. The two-branch if returning the same value was clearly unfinished (// TODO: support creating factory data), and silently handing viem { factoryData: undefined } defers the failure to bundler simulation where the error message ("account not deployed" / AA20) gives no hint that the root cause is a missing SDK parameter.
Also agree that deriving factoryData locally is unsafe: createAccount(bytes[] owners, uint256 nonce) needs the full owner set and nonce, and reconstructing that from a single owner + ownerIndex risks computing factory data for a different deterministic address than the one the account object was created with — a silent wrong-account deployment is strictly worse than a thrown error.
One edge case worth verifying before merge: getFactoryArgs() is not only called on the deploy path. viem also calls it when wrapping signatures in ERC-6492 format for undeployed accounts (signMessage/signTypedData on a counterfactual account produce a 6492-wrapped signature embedding factory + factoryData). If any SDK flow signs with an undeployed smart account that was created without factoryData, this change moves the failure from "invalid 6492 signature that fails verification downstream" to "throw at signing time". That's still the better behavior — but it means the error can now surface in sign flows, not just deploy flows, so the error message could mention both. Suggestion:
'Cannot generate factory args for an undeployed smart account: factoryData was not
provided and cannot be derived locally. Deployment and ERC-6492 signing both
require factoryData for undeployed accounts.'
Worth grepping the SDK for getFactoryArgs call sites (including via viem's toSmartAccount internals) to confirm which flows can hit the throw, and adding one test for the signing path if it applies. Otherwise LGTM — the regression tests cover both branches and the behavior change is strictly an improvement in failure locality.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #377.
What changed
getFactoryArgs()throw a clearBaseErrorwhenfactoryDatais missing.factoryDatapaths.Why
When
factoryDatais undefined, returning{ factory, factoryData: undefined }can silently produce no init code for an undeployed account and defer the failure to bundler/EntryPoint simulation. The SDK cannot safely derive Coinbase Smart Account factory data from only a single owner and owner index, so failing early is safer.Testing
git diff --checkcorepack yarn workspace @base-org/account test createSmartAccountcould not run because the local checkout has no Yarn state/install (Couldn't find the node_modules state file).