Repository navigation
style(python): tidy builder-code CBOR helpers - #36
Draft
PhilBot402 wants to merge 2 commits into
Draft
PhilBot402 wants to merge 2 commits into
PhilBot402 wants to merge 2 commits into
Conversation
…#3723) * feat(python): add builder-code settlement metadata m Port the facilitator-authored ERC-8021 Schema 2 field from the TypeScript and Go SDKs. Python now encodes and parses m, emits a suffix from metadata alone, ignores client-supplied m, and rejects CBOR larger than 65,535 bytes. Co-authored-by: phdargen <phdargen@users.noreply.github.com> * chore(python): name the builder-code changelog fragment Point the towncrier fragment at the upstream pull request. Co-authored-by: phdargen <phdargen@users.noreply.github.com> --------- Co-authored-by: phdargen <phdargen@users.noreply.github.com>
The settlement-metadata parser checked the buffer by calling peek_major and ignoring its result, and integer encoding repeated a range check that the major-type encoder already performs. Co-authored-by: phdargen <29732335+phdargen@users.noreply.github.com>
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.
Description
Style-only cleanup of the Python builder-code CBOR helpers added in x402-foundation#3723. Encoding and parsing behavior is unchanged.
_CborCursor.read_argumentcalledpeek_majorand ignored the return value, using it only as an end-of-buffer check. Integer metadata now goes straight to_encode_major_type, which already rejects values outsideuint64with the sameValueError. The top-level key dispatch is a flatif/elif, and an empty metadata dict is passed asm=metadata or Noneinstead of through a one-use local.No changelog fragment: this is not user-facing.
Tests
From
python/x402/:uvx ruff formatanduvx ruff checkon the touched modulesuv run pytestfor the builder-code unit testsuv run mypyon the touched modulesChecklist
AI disclosure: automated by @phdargen. Use your own judgement