Skip to content

feat(commerce): wrap @solana/mpp.charge with finalized-blockhash request override#9

Merged
vvillait88 merged 1 commit intomainfrom
feat/solana-mpp-finalized-blockhash-wrapper
May 5, 2026
Merged

feat(commerce): wrap @solana/mpp.charge with finalized-blockhash request override#9
vvillait88 merged 1 commit intomainfrom
feat/solana-mpp-finalized-blockhash-wrapper

Conversation

@vvillait88
Copy link
Copy Markdown
Contributor

Summary

  • Wrap @solana/mpp.charge()'s Method to override request and fetch the challenge blockhash with commitment: 'finalized' instead of the library's default confirmed.
  • Bumps @agent-score/commerce 1.3.0 → 1.3.1.

Why

@solana/mpp <= 0.5.2 fetches getLatestBlockhash at confirmed for its 402 challenge, but the server's broadcast sendTransaction is hardcoded to { skipPreflight: false } with no preflightCommitment override. The RPC's default preflight commitment is finalized (~30 slots / ~12s ahead of confirmed), so the preflight simulator rejects every fresh blockhash with Blockhash not found.

This shipped to martin-estate prod and broke every Solana smoke during the deploy cycle this morning. Same bug exists in every published @solana/mpp version 0.1.0 → 0.5.2.

We own the wrapper; not pursuing an upstream PR.

What changed

  • New exported helper wrapSolanaChargeWithFinalizedBlockhash(baseMethod, rpcUrl) in src/payment/mppx_server.ts.
  • createMppxServer's solana branch now wraps solanaMpp.charge(...) through the helper before pushing into methods[].
  • Helper falls back to upstream's confirmed blockhash on fetch failure or empty RPC response (no-op regression on errors).
  • 5 unit tests in tests/payment/wrap_solana_charge.test.ts covering: success path, verify-leg passthrough, fetch-throw fallback, missing-blockhash fallback, undefined-orig passthrough.

Trade-off: signing window shrinks ~58s → ~46s; fine for agent-driven flows.

Test plan

  • Unit tests pass (5/5)
  • Coverage clears global threshold (branches 90.06%, was 89.46%)
  • End-to-end devnet smoke: real settle through agentscore-pay --chain solana --network testnet against local martin-estate (sponsor-paid gas, buyer-signed SPL authority, 0.11 USDC moved on-chain)
  • After merge + publish, martin-estate bumps to 1.3.1 and re-runs mainnet smoke

🤖 Generated with Claude Code

…est override

@solana/mpp <=0.5.2 fetches getLatestBlockhash with commitment='confirmed' but its
broadcast sendTransaction sets skipPreflight:false without an overridden
preflightCommitment, so the RPC's default 'finalized' preflight rejects any
not-yet-finalized blockhash with "Blockhash not found". This shipped to martin-estate
prod and broke every solana/charge smoke during the release cycle.

Wrap solanaMpp.charge() so the issued challenge carries a finalized blockhash on
first try. Trade-off: agent signing window shrinks ~58s → ~46s, fine for agent
flows. Validated end-to-end on devnet against a local martin-estate (sponsor
pays gas, buyer-signed SPL authority, $0.11 USDC moved on-chain).

Bumps @agent-score/commerce 1.3.0 → 1.3.1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vvillait88 vvillait88 merged commit 8db92e2 into main May 5, 2026
6 checks passed
@vvillait88 vvillait88 deleted the feat/solana-mpp-finalized-blockhash-wrapper branch May 5, 2026 10:25
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