Skip to content

fix(aztec.js): honor fee payment method in BatchCall.simulate#24801

Open
Thunkar wants to merge 1 commit into
merge-train/fairies-v5from
grego/f-785-fixaztecjs-batchcallsimulate-ignores-the-fee-payment-method
Open

fix(aztec.js): honor fee payment method in BatchCall.simulate#24801
Thunkar wants to merge 1 commit into
merge-train/fairies-v5from
grego/f-785-fixaztecjs-batchcallsimulate-ignores-the-fee-payment-method

Conversation

@Thunkar

@Thunkar Thunkar commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

BatchCall.simulate() silently discarded options.fee.paymentMethod and dropped the merged payload's feePayer, so batches simulated with a sponsored/deferred fee method ran with the wallet's fallback handling (PREEXISTING_FEE_JUICE) instead of the caller's method. The wallet's account entrypoint then self-elected as fee payer and ended setup up front — a different phase structure than the caller asked for.

Resolves F-785. Surfaced while landing #24479.

Changes

  • batch_call.ts: fetch options.fee.paymentMethod.getExecutionPayload(), merge it ahead of the batch (mirroring request()), and preserve combinedPayload.feePayer when rebuilding the ExecutionPayload.
  • The wallet-side app-call offset only counts the wallet's own fee payment method, not one supplied via options.fee. So each batched call's private/public return-value index is offset by the fee payload's own call counts of each type; otherwise a call-contributing method (e.g. SponsoredFeePaymentMethod) shifts the indices and the fee call's return values decode as the first app call's.
  • contract_function_interaction.ts: fixed the same latent off-by-one under a call-contributing fee method. The single app call is the last of its type in the payload, so its index is derived from the merged payload (avoiding a second getExecutionPayload() call).
  • phase_check.parallel.test.ts: reverted the feat: assert non revertible phase when setting fee payer #24479 workaround back to the plain batch.simulate({ from, fee }) form now that the option is honored.

Testing

  • Added 3 batch_call unit tests: return-value index offset (asserting on actual decoded values, not just absence of errors), feePayer from the payment method, and feePayer carried by a batched payload. Verified red/green — the offset test fails without the fix.
  • All 3 phase_check e2e tests pass, including the reverted late-election test.
  • No behavior change for batches simulated without fee.paymentMethod (offsets are 0).

BatchCall.simulate() silently discarded options.fee.paymentMethod and
dropped the merged payload's feePayer, so batches simulated with a
sponsored/deferred fee method ran with the wallet's fallback handling
(PREEXISTING_FEE_JUICE) instead of the caller's method.

Merge the payment method's execution payload ahead of the batch (as
request() already does) and preserve combinedPayload.feePayer when
rebuilding the ExecutionPayload. Since the wallet's app-call offset only
counts the wallet's own fee payment method, offset each batched call's
private/public return-value index by the fee payload's own call counts of
each type; otherwise a call-contributing fee method (e.g.
SponsoredFeePaymentMethod) shifts the indices and the fee call's return
values decode as the first app call's.

Apply the same index offset to ContractFunctionInteraction.simulate(),
which had the same latent off-by-one under a call-contributing fee method.

Revert the phase_check late-election e2e test to the plain
batch.simulate({ from, fee }) form now that the option is honored.
@Thunkar
Thunkar requested a review from nventuro July 20, 2026 07:38
@Thunkar Thunkar self-assigned this Jul 20, 2026
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