Skip to content

Conversation

@QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented May 25, 2025

Issue being fixed or feature implemented

Added marketplace rules to the token configuration, allowing for the management of trade modes and associated control rules. This is to better future proof the system so people can register tokens now that can later have a marketplace.

What was done?

  • Introduced TokenMarketplaceRules and TokenMarketplaceRulesV0 structures.
  • Added accessors for marketplace rules to facilitate getting and setting trade modes and change control rules.
  • Updated TokenConfigurationChangeItem to include new items for marketplace trade mode and control groups.
  • Enhanced methods in TokenConfigurationV0 to handle the new marketplace rules.
  • Implemented validation checks for changes to marketplace rules during configuration updates.
  • Updated relevant tests to cover the new marketplace functionality.

How Has This Been Tested?

New unit tests were added to ensure the functionality of marketplace rules and their integration with existing token configuration logic.

Breaking Changes

None

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added ! to the title and described breaking changes in the corresponding section if my code contains any.

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Introduced marketplace rules to token configurations, allowing tokens to specify trade modes and control who can change these modes.
    • Added support for configuring and validating marketplace trade mode changes, including control and admin groups.
    • Extended token configuration options with new variants for marketplace trade mode management.
  • Bug Fixes

    • Improved validation and permission checks for marketplace-related configuration changes to ensure proper authorization and error handling.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 25, 2025

Walkthrough

A new marketplace rules subsystem for token configurations was introduced. This includes new modules, traits, data structures, and logic for handling marketplace trade modes and their change control rules. Existing token configuration methods were updated to support, validate, and authorize changes to these marketplace-related fields, with new enum variants and accessor traits added throughout.

Changes

File(s) Change Summary
.../associated_token/mod.rs Publicly exported new module: token_marketplace_rules.
.../token_marketplace_rules/mod.rs
.../token_marketplace_rules/v0/mod.rs
Added new TokenMarketplaceRules enum, versioned struct, trade mode enum, and display implementations.
.../token_marketplace_rules/accessors/mod.rs
.../token_marketplace_rules/accessors/v0/mod.rs
Added accessor and mutator traits for TokenMarketplaceRules and its V0 variant.
.../token_marketplace_rules/v0/accessors.rs Implemented getter/setter traits for TokenMarketplaceRulesV0.
.../token_configuration/v0/mod.rs Added marketplace_rules field to TokenConfigurationV0 with defaulting logic; updated preset methods.
.../token_configuration_item.rs Added three new enum variants for marketplace trade mode and related groups; updated index and display logic.
.../token_configuration/methods/apply_token_configuration_item/v0/mod.rs Extended method to handle new marketplace-related configuration change variants.
.../token_configuration/methods/authorized_action_takers_for_configuration_item/v0/mod.rs Extended method to handle new marketplace-related configuration change variants for authorization checks.
.../token_configuration/methods/can_apply_token_configuration_item/v0/mod.rs Extended method to handle new marketplace-related configuration change variants for permission checks.
.../token_configuration/methods/validate_token_configuration_update/v0/mod.rs Added validation logic for direct purchase pricing rules and marketplace rules updates.
.../initialization/create_genesis_state/test/tokens.rs Updated test setup to initialize new marketplace_rules field in token configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TokenConfig
    participant MarketplaceRules

    User->>TokenConfig: Propose configuration change (e.g., MarketplaceTradeMode)
    TokenConfig->>MarketplaceRules: Access trade_mode_change_rules()
    TokenConfig->>MarketplaceRules: Validate or apply change
    MarketplaceRules-->>TokenConfig: Result (allowed/denied or updated)
    TokenConfig-->>User: Respond with outcome
Loading

Suggested reviewers

  • pauldelucia

Poem

In a meadow of code where tokens reside,
New marketplace rules now hop in with pride.
Trade modes are guarded, with checks at the gate,
Only the worthy can alter their fate.
With traits and with enums, the logic expands—
A bunny’s delight in well-ordered lands!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2581ea2 and e04bc55.

📒 Files selected for processing (1)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/validate_token_configuration_update/v0/mod.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/validate_token_configuration_update/v0/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Formatting
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive-abci) / Unused dependencies
  • GitHub Check: Rust packages (drive-abci) / Formatting
  • GitHub Check: Rust packages (drive-abci) / Check each feature
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@QuantumExplorer QuantumExplorer changed the title feat: add marketplace rules to token configuration feat(dpp): add marketplace rules to token configuration May 25, 2025
@QuantumExplorer QuantumExplorer added this to the v2.0.0 milestone May 25, 2025
Copy link
Member Author

@QuantumExplorer QuantumExplorer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self reviewed

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs (1)

214-238: ⚠️ Potential issue

Update Display implementation to include marketplace_rules field.

The Display implementation is missing the newly added marketplace_rules field, creating an inconsistency with the struct definition.

Apply this diff to include the marketplace_rules field:

         write!(
             f,
-            "TokenConfigurationV0 {{\n  conventions: {:?},\n  conventions_change_rules: {:?},\n  base_supply: {},\n  max_supply: {:?},\n  keeps_history: {},\n  start_as_paused: {},\n  allow_transfer_to_frozen_balance: {},\n  max_supply_change_rules: {:?},\n  distribution_rules: {},\n  manual_minting_rules: {:?},\n  manual_burning_rules: {:?},\n  freeze_rules: {:?},\n  unfreeze_rules: {:?},\n  destroy_frozen_funds_rules: {:?},\n  emergency_action_rules: {:?},\n  main_control_group: {:?},\n  main_control_group_can_be_modified: {:?}\n}}",
+            "TokenConfigurationV0 {{\n  conventions: {:?},\n  conventions_change_rules: {:?},\n  base_supply: {},\n  max_supply: {:?},\n  keeps_history: {},\n  start_as_paused: {},\n  allow_transfer_to_frozen_balance: {},\n  max_supply_change_rules: {:?},\n  distribution_rules: {},\n  marketplace_rules: {},\n  manual_minting_rules: {:?},\n  manual_burning_rules: {:?},\n  freeze_rules: {:?},\n  unfreeze_rules: {:?},\n  destroy_frozen_funds_rules: {:?},\n  emergency_action_rules: {:?},\n  main_control_group: {:?},\n  main_control_group_can_be_modified: {:?}\n}}",
             self.conventions,
             self.conventions_change_rules,
             self.base_supply,
             self.max_supply,
             self.keeps_history,
             self.start_as_paused,
             self.allow_transfer_to_frozen_balance,
             self.max_supply_change_rules,
             self.distribution_rules,
+            self.marketplace_rules,
             self.manual_minting_rules,
             self.manual_burning_rules,
             self.freeze_rules,
             self.unfreeze_rules,
             self.destroy_frozen_funds_rules,
             self.emergency_action_rules,
             self.main_control_group,
             self.main_control_group_can_be_modified
         )
🧹 Nitpick comments (1)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/mod.rs (1)

14-17: Consider future extensibility for trade modes.

The TokenTradeMode enum currently only has NotTradeable variant. While this is appropriate for the initial implementation, consider documenting the design intention for future trade modes (e.g., Tradeable, RestrictedTradeable, etc.) to help guide future development.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c70e94b and 2581ea2.

📒 Files selected for processing (13)
  • packages/rs-dpp/src/data_contract/associated_token/mod.rs (1 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/apply_token_configuration_item/v0/mod.rs (2 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/authorized_action_takers_for_configuration_item/v0/mod.rs (2 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/can_apply_token_configuration_item/v0/mod.rs (2 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/validate_token_configuration_update/v0/mod.rs (2 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs (5 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration_item.rs (4 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/mod.rs (1 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/v0/mod.rs (1 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/mod.rs (1 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/accessors.rs (1 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/mod.rs (1 hunks)
  • packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: QuantumExplorer
PR: dashpay/platform#2257
File: packages/rs-drive-abci/src/mimic/test_quorum.rs:159-164
Timestamp: 2024-11-20T16:16:01.830Z
Learning: QuantumExplorer prefers not to receive auto-generated messages asking to post on social media.
🧬 Code Graph Analysis (3)
packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/apply_token_configuration_item/v0/mod.rs (3)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/mod.rs (1)
  • trade_mode (11-15)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/v0/mod.rs (1)
  • trade_mode (7-7)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/accessors.rs (1)
  • trade_mode (11-13)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/v0/mod.rs (2)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/mod.rs (5)
  • trade_mode (11-15)
  • trade_mode_change_rules (17-21)
  • trade_mode_change_rules_mut (23-27)
  • set_trade_mode (32-36)
  • set_trade_mode_change_rules (38-42)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/accessors.rs (5)
  • trade_mode (11-13)
  • trade_mode_change_rules (15-17)
  • trade_mode_change_rules_mut (19-21)
  • set_trade_mode (26-28)
  • set_trade_mode_change_rules (30-32)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/mod.rs (2)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/v0/mod.rs (5)
  • trade_mode (7-7)
  • trade_mode_change_rules (10-10)
  • trade_mode_change_rules_mut (13-13)
  • set_trade_mode (19-19)
  • set_trade_mode_change_rules (22-22)
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/accessors.rs (5)
  • trade_mode (11-13)
  • trade_mode_change_rules (15-17)
  • trade_mode_change_rules_mut (19-21)
  • set_trade_mode (26-28)
  • set_trade_mode_change_rules (30-32)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Rust packages (drive-abci) / Check each feature
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (drive-abci) / Unused dependencies
  • GitHub Check: Rust packages (drive-abci) / Formatting
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp) / Formatting
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (27)
packages/rs-dpp/src/data_contract/associated_token/mod.rs (1)

8-8: LGTM! Clean module addition.

The addition of the token_marketplace_rules module follows the established pattern and correctly exposes the new marketplace functionality.

packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs (2)

12-12: LGTM! Proper import addition.

The import for TokenMarketplaceRulesV0 is correctly added to support the new marketplace rules functionality in the test configuration.


265-269: LGTM! Consistent field initialization.

The marketplace_rules field is properly initialized with appropriate defaults:

  • Default trade mode (likely non-tradeable based on the context)
  • Default change control rules wrapped in ChangeControlRulesV0

This follows the same initialization pattern as other rule fields in the token configuration.

packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/apply_token_configuration_item/v0/mod.rs (2)

6-8: LGTM! Appropriate accessor imports.

The imports for TokenMarketplaceRulesV0Getters and TokenMarketplaceRulesV0Setters are correctly added to support the new marketplace rules functionality.


141-153: LGTM! Comprehensive marketplace rules handling.

The three new match cases properly handle marketplace-related configuration changes:

  1. MarketplaceTradeMode - Sets the trade mode using the setter method
  2. MarketplaceTradeModeControlGroup - Updates the authorized action takers for trade mode changes
  3. MarketplaceTradeModeAdminGroup - Updates the admin action takers for trade mode changes

The implementation follows the established pattern used by other configuration items and correctly delegates to the appropriate accessor methods.

packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/authorized_action_takers_for_configuration_item/v0/mod.rs (2)

4-4: LGTM! Required accessor import.

The import for TokenMarketplaceRulesV0Getters is correctly added to access marketplace rules for authorization checks.


109-120: LGTM! Correct authorization logic for marketplace rules.

The three new match cases properly determine authorized action takers for marketplace configuration changes:

  1. MarketplaceTradeMode - Returns the authorized action takers for trade mode changes
  2. MarketplaceTradeModeControlGroup & MarketplaceTradeModeAdminGroup - Both return admin action takers since these are control group modifications

The implementation correctly delegates to marketplace_rules.trade_mode_change_rules() and follows the established authorization pattern used throughout the codebase.

packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/can_apply_token_configuration_item/v0/mod.rs (2)

4-4: LGTM: Clean import addition.

The import for TokenMarketplaceRulesV0Getters is properly added and follows the existing import structure.


294-319: Excellent implementation following established patterns.

The three new marketplace-related match arms consistently follow the same delegation pattern as existing configuration items:

  • Permission checks are properly delegated to the marketplace rules' change control system
  • All required parameters are correctly passed through
  • The structure mirrors other similar variants (e.g., conventions, max_supply variants)

This consistency ensures maintainability and correctness of the authorization system.

packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/v0/mod.rs (1)

1-24: Excellent trait design with clear separation of concerns.

The trait definitions demonstrate good Rust practices:

  • Clean separation between read (TokenMarketplaceRulesV0Getters) and write operations (TokenMarketplaceRulesV0Setters)
  • Comprehensive documentation for all methods
  • Consistent naming conventions
  • Proper handling of mutable vs immutable access patterns

The inclusion of trade_mode_change_rules_mut() alongside the immutable getter provides flexible access to the change control rules.

packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/accessors.rs (1)

1-34: Clean and straightforward trait implementations.

The implementations are well-executed:

  • Simple, direct field access for getters with appropriate reference types
  • Clean setter implementations with direct assignment
  • No unnecessary complexity or potential error sources
  • Consistent with the trait definitions and follows expected patterns

The code is easy to understand and maintain.

packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/mod.rs (1)

1-27: Excellent implementation following established versioning patterns.

The TokenMarketplaceRules enum demonstrates good architectural practices:

  • Versioning: Proper use of #[serde(tag = "$format_version")] for future extensibility
  • Derives: Appropriate trait derivations for serialization, debugging, and comparison
  • Display: Clean delegation to the inner V0 variant implementation
  • Module structure: Well-organized with separate accessors and v0 submodules

The implementation is consistent with other versioned enums in the codebase and sets up a solid foundation for future marketplace rule enhancements.

packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/mod.rs (1)

1-43: LGTM! Clean accessor implementation following established patterns.

The accessor implementation correctly follows the delegation pattern used throughout the codebase, where the enum wrapper delegates method calls to the inner versioned implementation. The code is well-structured with clear separation of getters and setters, and the pattern matching is exhaustive for the current V0 variant.

packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/v0/mod.rs (2)

27-35: Excellent security-first default configuration.

The default_change_control_rules function correctly initializes a very restrictive configuration where no one can make changes by default. This follows the principle of least privilege and ensures that marketplace rules can only be modified when explicitly configured with appropriate authorization.


37-48: Well-formatted Display implementation.

The Display implementation provides clear, readable output with proper formatting and includes all relevant fields. The multi-line format makes it easy to read the marketplace rules configuration.

packages/rs-dpp/src/data_contract/associated_token/token_configuration_item.rs (4)

3-3: Correct import addition for marketplace functionality.

The import of TokenTradeMode is properly added to support the new marketplace-related enum variants.


63-66: Well-structured marketplace enum variants.

The three new marketplace-related variants follow the established naming convention and pattern:

  • MarketplaceTradeMode for the trade mode value
  • MarketplaceTradeModeControlGroup for control group authorization
  • MarketplaceTradeModeAdminGroup for admin group authorization

This maintains consistency with other configuration items in the enum.


99-102: Correct index assignment and reordering.

The index assignment correctly assigns sequential indices (28, 29, 30) to the new marketplace variants and appropriately shifts MainControlGroup to index 31. This maintains the sequential ordering while accommodating the new variants.


226-234: Consistent Display implementation for marketplace variants.

The Display implementation for the new marketplace variants follows the same format and style as existing variants, using appropriate formatting for the contained data types.

packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/validate_token_configuration_update/v0/mod.rs (3)

5-5: Correct import addition for marketplace rules validation.

The import of TokenMarketplaceRulesV0Getters is properly added to support validation of the new marketplace rules fields.


163-195: Proper validation logic for direct purchase pricing rules.

The validation block correctly follows the established pattern for checking field changes and validating permissions using the can_change_to method. The error message and field identification are appropriate.


199-226: Correct validation implementation for marketplace rules.

The validation logic properly checks for changes to both the trade mode and its change rules, then validates permissions using the can_change_to method. The error message correctly identifies the marketplace-related fields being validated.

packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs (5)

10-13: LGTM! Clean import statements for marketplace rules.

The imports follow the established patterns and properly bring in the necessary marketplace rules types.


77-79: LGTM! Well-documented and properly positioned field.

The new marketplace_rules field is appropriately placed, follows the same pattern as other rule fields, and includes clear documentation explaining its purpose.


181-192: LGTM! Sensible default implementation for marketplace rules.

The default function correctly initializes marketplace rules with:

  • NotTradeable mode (safe default)
  • Restrictive change control rules (NoOne can make changes)
  • Consistent pattern with other default rule functions

This provides a secure default configuration that prevents trading until explicitly enabled.


438-443: LGTM! Consistent preset implementation.

The default_marketplace_rules_v0() method properly follows the preset pattern by using default_basic_change_control_rules_v0() for consistency with other preset configurations while maintaining the safe NotTradeable default.


468-468: LGTM! Proper integration of marketplace rules.

The marketplace rules are correctly integrated into the token configuration creation process using the preset's default marketplace rules method.

@QuantumExplorer QuantumExplorer merged commit 3d5328e into v2.0-dev May 25, 2025
122 of 125 checks passed
@QuantumExplorer QuantumExplorer deleted the featadd-marketplace-rules branch May 25, 2025 07:16
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.

2 participants