Skip to content

Conversation

@levalleux-ludo
Copy link
Member

@levalleux-ludo levalleux-ludo marked this pull request as ready for review February 12, 2026 18:00
Copilot AI review requested due to automatic review settings February 12, 2026 18:00
Copy link
Contributor

Copilot AI left a 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 metadataType and additional schemas via yupSchemas (e.g. BUNDLE, ITEM_PRODUCT_V1).
  • Update core-sdk checkExchangePolicy to 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);
Copy link

Copilot AI Feb 12, 2026

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.

Suggested change
const tokensList = defaultTokens.map((token) => token.address);

Copilot uses AI. Check for mistakes.
Comment on lines 36 to 54
// // 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
Copy link

Copilot AI Feb 12, 2026

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.

Suggested change
// // 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 uses AI. Check for mistakes.
}
}
}
console.log("rulesTemplate", rulesTemplate);
Copy link

Copilot AI Feb 12, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check ExchangePolicy rules is not working with Bundle offer

1 participant