-
Notifications
You must be signed in to change notification settings - Fork 1
feat: adapt check exchange policy for bundle offers #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| disputeResolverId_matches; | ||
| } | ||
| // replace TOKENS_LIST (environment dependent) | ||
| const tokensList = defaultTokens.map((token) => token.address); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokensList is computed here but never used. Either remove it, or reuse this precomputed list in the <TOKENS_LIST> replacement inside the loop to avoid recalculating.
| const tokensList = defaultTokens.map((token) => token.address); |
| // // replace DEFAULT_DISPUTE_RESOLVER_ID (environment dependent) | ||
| // const disputeResolverId_matches = | ||
| // rulesTemplate?.yupSchema?.properties?.disputeResolverId?.matches?.replace( | ||
| // "<DEFAULT_DISPUTE_RESOLVER_ID>", | ||
| // defaultDisputeResolverId | ||
| // ); | ||
| // if (disputeResolverId_matches) { | ||
| // rulesTemplate.yupSchema.properties.disputeResolverId.matches = | ||
| // disputeResolverId_matches; | ||
| // } | ||
| // // replace TOKENS_LIST (environment dependent) | ||
| // const tokensList_pattern = | ||
| // rulesTemplate?.yupSchema?.properties?.exchangeToken?.properties?.address?.pattern?.replace( | ||
| // "<TOKENS_LIST>", | ||
| // tokensList.join("|") | ||
| // ); | ||
| // if ( | ||
| // rulesTemplate.yupSchema.properties.exchangeToken.properties && | ||
| // tokensList_pattern |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the commented-out legacy replacement code that starts here (and continues below). Leaving large commented blocks in production hooks makes the current behavior harder to reason about and maintain.
| // // replace DEFAULT_DISPUTE_RESOLVER_ID (environment dependent) | |
| // const disputeResolverId_matches = | |
| // rulesTemplate?.yupSchema?.properties?.disputeResolverId?.matches?.replace( | |
| // "<DEFAULT_DISPUTE_RESOLVER_ID>", | |
| // defaultDisputeResolverId | |
| // ); | |
| // if (disputeResolverId_matches) { | |
| // rulesTemplate.yupSchema.properties.disputeResolverId.matches = | |
| // disputeResolverId_matches; | |
| // } | |
| // // replace TOKENS_LIST (environment dependent) | |
| // const tokensList_pattern = | |
| // rulesTemplate?.yupSchema?.properties?.exchangeToken?.properties?.address?.pattern?.replace( | |
| // "<TOKENS_LIST>", | |
| // tokensList.join("|") | |
| // ); | |
| // if ( | |
| // rulesTemplate.yupSchema.properties.exchangeToken.properties && | |
| // tokensList_pattern |
| } | ||
| } | ||
| } | ||
| console.log("rulesTemplate", rulesTemplate); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this console.log. Logging the full rules template in a hook will spam production logs and can expose internal configuration details.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…com/bosonprotocol/core-components into 998-check-exchangepolicy-for-bundle
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