Skip to content

feat: add zero_amount_carve_out helper - #26

Merged
vvillait88 merged 1 commit into
mainfrom
tec-302-zero-amount
May 14, 2026
Merged

feat: add zero_amount_carve_out helper#26
vvillait88 merged 1 commit into
mainfrom
tec-302-zero-amount

Conversation

@vvillait88

Copy link
Copy Markdown
Contributor

Summary

  • Skip upstream verify+settle for $0 orders (redemption-code flow). CDP rejects EIP-3009 `value=0` as `invalid_payload`; pympp's tempo intents reject the `proof` payload for $0 settles. The helper parses the credential and lifts the signer for wallet-capture attribution.
  • Returns `ZeroSettleResult{ signer_address, signer_network, tx_hash=None }`. Same shape as `process_x402_settle` success so callers can branch on rail, not on shape.
  • For `rail="x402-base"`: pass `payload` (verified x402 dict). For `rail="tempo"`/`"solana"`: pass `authorization_header` (Payment <base64>).
  • Exported from `agentscore_commerce.payment`.

Tests

  • 14-fixture corpus locked as the cross-language contract with `@agent-score/commerce`'s `zeroAmountCarveOut`.
  • Parametrized via `pytest.mark.parametrize` so multiple drifts surface independently.
  • Invariants: `tx_hash` always `None`; rail dispatch ignores irrelevant args.

Test plan

  • `uv run pytest tests/test_zero_settle.py` — 18 tests pass
  • `uv run pytest` — full suite 981 pass / 3 skip, coverage 95.16%
  • `uv run ruff check`, `uv run ruff format --check`, `uv run ty check` — green

🤖 Generated with Claude Code

Skip upstream verify+settle for $0 orders (e.g. redemption-code flow).
CDP rejects EIP-3009 transferWithAuthorization with value=0 as
invalid_payload; pympp's tempo intents reject the `proof` payload mppx
emits for $0 settles. The helper parses the credential and lifts the
signer for wallet-capture attribution, returning ZeroSettleResult{
signer_address, signer_network, tx_hash=None }.

For rail="x402-base": pass the verified x402 payload dict; reads
payload.payload.authorization.from.

For rail="tempo" or "solana": pass the Authorization: Payment <base64>
header; reads the did:pkh:* source DID via extract_payment_signer (302a).

Tests lock 14 cross-language fixtures with the @agent-score/commerce
sibling. Parametrized so multiple drifts surface independently.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vvillait88
vvillait88 merged commit b22ec4c into main May 14, 2026
7 checks passed
@vvillait88
vvillait88 deleted the tec-302-zero-amount branch May 14, 2026 15:43
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