Skip to content

refactor: encapsulate userCallOffset logic in TxSimulationResult#21886

Closed
benesjan wants to merge 1 commit into
merge-train/fairiesfrom
be/refactor-user-call-offset
Closed

refactor: encapsulate userCallOffset logic in TxSimulationResult#21886
benesjan wants to merge 1 commit into
merge-train/fairiesfrom
be/refactor-user-call-offset

Conversation

@benesjan

@benesjan benesjan commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Closes https://linear.app/aztec-labs/issue/F-483/handle-simulation-with-nested-calls-and-without-account-contract

Summary

Approach (V1 — this PR): Encapsulates offset usage on TxSimulationResult:

  • Adds getUserPrivateReturnValues(callIndex) to TxSimulationResult, encapsulating the branching on userCallOffset being undefined (DefaultEntrypoint / root call) vs a number (account contract / nested call after fee preamble)
  • createTxExecutionRequestFromPayloadAndFee now returns { txRequest, userCallOffset } instead of { txRequest, feeCallCount } — the conversion from fee call count to offset (including the NO_FROM check) now lives inside the method where the fee logic already is
  • Consumers (ContractFunctionInteraction, BatchCall) replaced multi-line branching blocks with single calls to getUserPrivateReturnValues
  • Keeps the compound return from createTxExecutionRequestFromPayloadAndFee and post-simulation mutation of result.userCallOffset

Alternative approach (V2 — #21937): Goes further by also separating concerns in the wallet layer:

  • createTxExecutionRequestFromPayloadAndFee returns just a TxExecutionRequest (no compound return)
  • A dedicated computeUserCallOffset helper derives the offset from fee options
  • userCallOffset threaded through constructors instead of post-construction mutation
  • Callers that don't need the offset (sendTx, profileTx) no longer destructure

🤖 Generated with Claude Code

Adds `getUserPrivateReturnValues(callIndex)` to `TxSimulationResult`
so callers no longer need to branch on `userCallOffset` being defined
or not. Also moves the offset calculation into
`createTxExecutionRequestFromPayloadAndFee` so it returns
`{ txRequest, userCallOffset }` instead of `{ txRequest, feeCallCount }`,
removing the leaky abstraction.

Closes F-483

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@benesjan benesjan closed this Mar 25, 2026
@benesjan benesjan deleted the be/refactor-user-call-offset branch March 25, 2026 05:30
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.

1 participant