Skip to content

fix: short-circuit ensureAllowance when returnTxInfo is set#1034

Merged
zajck merged 4 commits into
mainfrom
fix/skip-ensure-allowance-when-return-tx-info
May 28, 2026
Merged

fix: short-circuit ensureAllowance when returnTxInfo is set#1034
zajck merged 4 commits into
mainfrom
fix/skip-ensure-allowance-when-return-tx-info

Conversation

@zajck

@zajck zajck commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

  • The handler functions in core-sdk (commitToOffer, commitToBuyerOffer, commitToConditionalOffer, createOfferAndCommit, commitToOfferAndRedeemVoucher, commitToConditionalOfferAndRedeemVoucher, createOfferCommitAndRedeem) all support returnTxInfo: true for callers (e.g. the MCP server) that only need the encoded transaction.
  • However, they all invoked ensureAllowance unconditionally, which attempts an ERC20 approve transaction and breaks for callers without a signer.
  • Centralize the fix: ensureAllowance now short-circuits when returnTxInfo is true, and every call site passes the flag through.

Test plan

  • Call each affected handler with returnTxInfo: true and an ERC20 exchange token — verify it returns a TransactionRequest without hitting ensureAllowance/approve.
  • Call each handler with returnTxInfo unset / false — verify allowance is still ensured before sending the transaction.

🤖 Generated with Claude Code

zajck and others added 2 commits May 28, 2026 15:52
…Info is set

Callers that only need the encoded transaction (e.g. the MCP server) cannot
perform the allowance check, which requires a signer. Mirror the existing
return-only flow by bypassing ensureAllowance when returnTxInfo is true.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Push the returnTxInfo check down into ensureAllowance so every caller that
already plumbs returnTxInfo through (commitToOffer, commitToBuyerOffer,
commitToConditionalOffer, createOfferAndCommit, commitToOfferAndRedeemVoucher,
commitToConditionalOfferAndRedeemVoucher, createOfferCommitAndRedeem) skips
the allowance check uniformly. Avoids the MCP server failure mode where no
signer is available to send an ERC20 approve transaction.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@zajck zajck changed the title fix: skip ensureAllowance in createOfferCommitAndRedeem when returnTxInfo is set fix: short-circuit ensureAllowance when returnTxInfo is set May 28, 2026
zajck and others added 2 commits May 28, 2026 16:06
ensureAllowance now widens returnTxInfo to boolean. Pass returnTxInfo: false
explicitly when calling approve() so TypeScript picks the TransactionResponse
overload (the one with .wait()).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@zajck
zajck merged commit 5207679 into main May 28, 2026
5 of 6 checks passed
@zajck
zajck deleted the fix/skip-ensure-allowance-when-return-tx-info branch May 28, 2026 15:06
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