Rewrite SDK around current receipt contract#23
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
receiptobject the single source of truth.Description
buildCommonsRequest/build_commons_requestandbuildCommercialRequest/build_commercial_request) and made client verb methods emit the canonical Commons envelope (x402,actor, body) by default in both SDKs.receipt.x402,metadata.proof, andmetadata.receipt_id, and addedextractReceiptVerb/extract_receipt_verbhelpers to read the canonicalreceipt.x402.verb.receipt, (2) stripmetadata.receipt_idand signature/hash fields to form the unsigned receipt, (3) canonicalize withcl-stable-json-v1, (4) recomputesha256, (5) requiremetadata.receipt_id === metadata.proof.hash_sha256, and (6) verify Ed25519 signature over the UTF‑8 hash string; ENS signer resolution now emits clear errors on missing/malformed TXT records.metadata.receipt_idis the receipt hash identifier and must equalmetadata.proof.hash_sha256; README, QUICKSTART, EXAMPLES, and package READMEs were rewritten to teach the single canonical contract.normalizeCommandResponse/normalize_command_response(accept older blended payloads with top-leveltraceand convert to{ receipt, runtime_metadata }) and support for passing either a rawreceiptor full response envelope into verification helpers; both are explicitly marked compatibility-only.response.receipt(notruntime_metadata), switch any implicit verb discovery toreceipt.x402.verbor the new extraction helpers, and move payment/commercial shaping into the dedicated commercial builders where needed.Testing
cd typescript-sdk && npm test(unit + template + CLI smoke); all tests passed and DTS/typecheck completed successfully.cd typescript-sdk && npm run typecheck; the typecheck succeeded.cd python-sdk && pytest; test suite passed (24 passed, 1 warning) and parity vectors remain aligned.Codex Task