feat: adapt check exchange policy for bundle offers#999
feat: adapt check exchange policy for bundle offers#999levalleux-ludo merged 22 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the exchange policy validation flow to support Bundle offers by allowing multiple Yup schema templates (selected by metadata.type) and adds core-sdk tests/fixtures to cover bundle validation.
Changes:
- Extend exchange policy rules format to support
metadataTypeand additional schemas viayupSchemas(e.g.BUNDLE,ITEM_PRODUCT_V1). - Update core-sdk
checkExchangePolicyto select the appropriate schema based on offer metadata type and to validate bundle items. - Update react-kit defaults/storybook config to use the new rules template IPFS hash and adjust rules-template placeholder replacement for multiple schemas.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-kit/src/stories/widgets/Commit.stories.tsx | Updates Storybook stories to use the new exchange policy rules IPFS hash. |
| packages/react-kit/src/hooks/useCheckExchangePolicy.ts | Applies placeholder replacements across the base schema and additional yupSchemas (but includes leftover debug/commented code). |
| packages/react-kit/src/components/boson/BosonProvider.tsx | Updates the default fairExchangePolicyRules IPFS hash. |
| packages/core-sdk/tests/exchangePolicy/exchangePolicyRules.testing.json | Adds metadataType + additional schemas for bundle/item validation and updates an error message. |
| packages/core-sdk/tests/exchangePolicy/examples/validBundle.json | Adds a valid bundle fixture for tests. |
| packages/core-sdk/tests/exchangePolicy/examples/invalidBundle.json | Adds an invalid bundle fixture for tests. |
| packages/core-sdk/tests/check-exchange-policy.test.ts | Adds bundle validation test cases and updates expected error messaging. |
| packages/core-sdk/src/offers/checkExchangePolicy.ts | Implements schema selection by metadata type + bundle item validation logic. |
| data/ipfs.txt | Records the new IPFS hash for traceability. |
| data/exchangePolicies/exchangePolicyRules.template.json | Updates the IPFS template to include bundle/item schemas and metadataType. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…com/bosonprotocol/core-components into 998-check-exchangepolicy-for-bundle
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/react-kit/src/components/offerPolicy/OfferPolicyDetails.tsx
Outdated
Show resolved
Hide resolved
…ls.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/react-kit/src/components/offerPolicy/OfferPolicyDetails.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ls.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@levalleux-ludo I've opened a new pull request, #1000, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@levalleux-ludo I've opened a new pull request, #1001, to work on those changes. Once the pull request is ready, I'll request review from you. |
#1000) * Initial plan * Add type checking for Yup ValidationError before accessing inner property Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> * Fix spacing in function call Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com>
|
|
…ling (#1001) * Initial plan * Add error type checking for Yup ValidationError handling Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> * Refactor: extract error validation logic into helper function Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> * Improve error property extraction to be more explicit Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> * Improve type safety in error extraction helper Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> * Add comprehensive JSDoc documentation for error extraction helper Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> * fix lint * fix test --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: levalleux-ludo <7184124+levalleux-ludo@users.noreply.github.com> Co-authored-by: Ludovic Levalleux <levalleux_ludo@hotmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #999 +/- ##
==========================================
- Coverage 90.98% 90.93% -0.06%
==========================================
Files 176 176
Lines 7190 7247 +57
Branches 1322 1355 +33
==========================================
+ Hits 6542 6590 +48
- Misses 648 657 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|



Description
fixes #998
How to test
Storybook
http://localhost:6006/?path=/story/widgets-commit--commit-bundle&args=configId:testing-80002-0;bundleUuid:d0d3fb4-34cd-0e78-a3a8-adeb2a434f;sellerId:2