Add offer construction and verification bindings#359
Open
hoffmang9 wants to merge 8 commits intoxch-dev:mainfrom
Open
Add offer construction and verification bindings#359hoffmang9 wants to merge 8 commits intoxch-dev:mainfrom
hoffmang9 wants to merge 8 commits intoxch-dev:mainfrom
Conversation
Add a binding helper that converts an input spend bundle and xch requested payments into a canonical offer spend bundle through Offer::from_input_spend_bundle.
Expose verify_offer for Python by decoding offer text and validating it through Offer::from_spend_bundle before downstream venue submission.
Centralize offer decode/parse validation in chia-sdk-driver with validate_offer_str and keep bindings verify_offer as a thin wrapper. Co-authored-by: Cursor <cursoragent@cursor.com>
Change verify_offer to return unit on success and propagate errors on invalid offers, and align bindings metadata and Python stubs with that contract. Co-authored-by: Cursor <cursoragent@cursor.com>
Use validation-focused naming across bindings and align the checked-in NAPI JS/TS surface with the new function plus from_input_spend_bundle exports. Co-authored-by: Cursor <cursoragent@cursor.com>
Cover validate_offer_str and validate_offer with positive and negative cases, and verify from_input_spend_bundle output parses into expected requested payment data. Co-authored-by: Cursor <cursoragent@cursor.com>
Clarify API semantics by renaming from_input_spend_bundle to from_input_spend_bundle_xch (and corresponding NAPI/Python names) so callers do not assume multi-asset requested payment support. Co-authored-by: Cursor <cursoragent@cursor.com>
This updates formatting-only diffs and replaces an unnecessary unwrap in tests so the Rust workflow passes reliably. Co-authored-by: Cursor <cursoragent@cursor.com>
Author
|
I went another way in my project but it does seem like folks wanting good access to Offers in python, etc could use these. Happy to drop it, also happy to go another way with changes here. |
Collaborator
|
I'm considering taking this change for now, but long term I want a whole Offer class that's a mirror of the SDK's Offer class for full functionality |
Author
|
If you're going to do it better, I don't need that soon so I lean reject it |
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.
Exposes two new offer-related functions through the Python/WASM bindings:
from_input_spend_bundle— Converts an input spend bundle and a set of XCH requested payments into a canonical offer spend bundle viaOffer::from_input_spend_bundle. This enables callers to programmatically construct valid offers from pre-built spends without going through the full wallet offer flow.verify_offer— Decodes an offer string and validates it by parsing throughOffer::from_spend_bundle, returningtrueif the offer is structurally valid. Useful for pre-validating offers before downstream submission (e.g. to a DEX or exchange venue).Both functions are added to the binding definitions (
offer.json), the Rust binding implementations, and the Python type stubs.