Skip to content

Conversation

@kristiehuang
Copy link
Collaborator

@kristiehuang kristiehuang commented Dec 8, 2025

Description

needed new encodeUserOp function in the smart wallet SDK for userops

How Has This Been Tested?

Are there any breaking changes?

no breaking changes, just adding a new fn


✨ Claude-Generated Content

Description

needed new encodeUserOp function in the smart wallet SDK for userops

How Has This Been Tested?

Are there any breaking changes?

no breaking changes, just adding a new fn

✨ Claude-Generated Content

Description

Adds a new encodeUserOp static method to the SmartWallet class for encoding UserOperation calldata compatible with ERC-4337 EntryPoint v0.7.0 and v0.8.0. This enables the smart wallet SDK to generate calldata for account abstraction user operations.

Changes

  • Added SmartWallet.encodeUserOp(calls, options) method that:
    • Takes an array of Call objects and optional ExecuteOptions
    • Uses CallPlanner and BatchedCallPlanner to encode the calls
    • Prepends the executeUserOp selector (0x8dd7712f) to the encoded data
    • Returns MethodParameters with calldata and aggregated value
  • Added comprehensive unit tests covering:
    • Single and multiple call encoding
    • Value aggregation across calls
    • revertOnFailure option (true/false/default)
    • Calls with chainId property

How Has This Been Tested?

  • Unit tests added for all encodeUserOp functionality
  • Manually verified by porting to trading API and executing a swap userop on-chain

Are there any breaking changes?

No - this is a purely additive change that adds a new method without modifying existing functionality.

@kristiehuang kristiehuang requested a review from a team as a code owner December 8, 2025 20:37
@kristiehuang kristiehuang changed the title feat(smart-wallet): add executeUserOp feat(smart-wallet-sdk): add executeUserOp Dec 8, 2025
@graphite-app graphite-app bot requested a review from a team December 8, 2025 20:50
@graphite-app
Copy link

graphite-app bot commented Dec 8, 2025

Graphite Automations

"Request reviewers once CI passes on sdks monorepo" took an action on this PR • (12/08/25)

2 reviewers were added and 1 assignee was added to this PR based on Siyu Jiang (See-You John)'s automation.

Comment on lines +133 to +149
it('handles calls with chainId property', () => {
const calls: Call[] = [
{
to: '0x1111111111111111111111111111111111111111',
data: '0x1234',
value: 50n,
chainId: ChainId.SEPOLIA,
},
]

const result = SmartWallet.encodeUserOp(calls)

expect(result).toBeDefined()
expect(result.calldata.startsWith(EXECUTE_USER_OP_SELECTOR)).toBe(true)
expect(result.value).toBe(50n)
})
})
Copy link
Contributor

Choose a reason for hiding this comment

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

this test doesn't really make sense, should be "handles value properly" or check chainId somehow

Choose a reason for hiding this comment

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

Agreed - this test doesn't add meaningful coverage since chainId isn't used in the encoding. Consider renaming to "handles value property" and removing the unused chainId, or removing the test entirely since value summation is already covered by the "sums the value of all calls" test.

const result = SmartWallet.encodeUserOp(calls)

expect(result).toBeDefined()
expect(result.calldata).toBeDefined()
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just add a quick test to check the to and data fields bc the other tests only check revertOnFailure not these other fields

Choose a reason for hiding this comment

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

Agreed - the first test at line 16-31 (and this one) only check the selector and value. Adding assertions that decode and verify the to and data fields would make these tests more comprehensive, similar to how the revertOnFailure tests decode the full structure.

@github-actions
Copy link

github-actions bot commented Dec 14, 2025

🤖 Claude Code Review

Review complete

Summary

This PR adds a new encodeUserOp static method to the SmartWallet class for encoding UserOperations compatible with ERC-4337 EntryPoint versions v0.7.0 and v0.8.0. The implementation correctly uses the executeUserOp selector (0x8dd7712f) and properly encodes the batched call data.

Review

The implementation looks correct:

  1. Encoding logic - Uses concatHex to properly combine the selector with the ABI-encoded batched call data, which is the correct approach given the non-standard call format for executeUserOp.

  2. Value aggregation - Properly sums all call values via planner.value.

  3. Options handling - Correctly delegates revertOnFailure to BatchedCallPlanner, which defaults to true.

  4. Tests - Good coverage of the core functionality including single/multiple calls, value summing, and revertOnFailure options.

Feedback on Existing Comments

@zhongeric raised two valid points about test coverage that haven't been addressed in the current code:

  1. Line 149: The "handles calls with chainId property" test doesn't actually verify anything specific to chainId - it just checks value and selector which are already covered by other tests.

  2. Line 50: The first "encodes multiple calls correctly" test only verifies the selector and value, but doesn't decode and check that to and data fields are properly encoded (unlike the revertOnFailure tests which do decode and verify the structure).

These are reasonable improvements but not blocking issues.


💡 Want a fresh review? Add a comment containing @request-claude-review to trigger a new review at any time.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

📋 Review verdict: APPROVE

👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.

This formal review submission is for the verdict only.

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