Skip to content

Conversation

@armyhaylenko
Copy link
Contributor

No description provided.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Default)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct GetTokenAccounts {
pub owner_address: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change owner and mint parameters names?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@armyhaylenko armyhaylenko force-pushed the feature/MTG-1451-align-das-payloads-with-reference branch from f54d5bb to d0ed5bb Compare March 18, 2025 10:39
Copy link
Contributor

@n00m4d n00m4d left a comment

Choose a reason for hiding this comment

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

LGTM!

@armyhaylenko armyhaylenko force-pushed the feature/MTG-1451-align-das-payloads-with-reference branch from d0ed5bb to 7327bca Compare March 25, 2025 13:19
@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2025

Summary by CodeRabbit

  • Refactor

    • Consolidated asset display configuration into a unified settings structure, ensuring consistency in asset retrieval and filtering across the platform.
  • Enhancements

    • Improved default handling for asset display preferences to deliver a more robust and reliable experience during asset searches and presentations.

Walkthrough

The changes refactor API request parameter handling by replacing the types Options, GetByMethodsOptions, and SearchAssetsOptions with a unified DisplayOptions struct. Field signatures in various asset-related requests have been updated to use Option<DisplayOptions>. Corresponding conversion implementations and default value usages have been modified accordingly. These updates are consistently applied across entities, integration tests, NFT ingester API implementations and tests, Postgre client methods and tests, and Rocks-DB client functions.

Changes

File(s) Change Summary
entities/src/api_req_params.rs Removed Options, SearchAssetsOptions, and GetByMethodsOptions; added DisplayOptions; updated field types in asset request structs to use Option<DisplayOptions> with alias support.
integration_tests (account_update_tests.rs, cnft_tests.rs) Changed test payloads to use Some(DisplayOptions::default()) instead of previous types; updated import statements accordingly.
nft_ingester (api_impl.rs, dapi/.rs, util.rs, tests/.rs) Replaced Options/GetByMethodsOptions with DisplayOptions in API method signatures and test cases; adjusted default handling and destructuring in request processing.
postgre-client (src/asset_filter_client.rs, storage_traits.rs, tests/asset_filter_client_test.rs) Updated method and function signatures to accept DisplayOptions instead of GetByMethodsOptions; modified filter-building functions and test instantiations accordingly.
rocks-db/src/clients/asset_client.rs Changed method parameter type from Options to DisplayOptions in get_asset_selected_maps_async; updated corresponding import statements.
✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

Copy link

@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: 4

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c63985c and 7327bca.

📒 Files selected for processing (17)
  • entities/src/api_req_params.rs (9 hunks)
  • integration_tests/src/account_update_tests.rs (2 hunks)
  • integration_tests/src/cnft_tests.rs (18 hunks)
  • nft_ingester/src/api/api_impl.rs (5 hunks)
  • nft_ingester/src/api/dapi/asset.rs (3 hunks)
  • nft_ingester/src/api/dapi/get_asset.rs (2 hunks)
  • nft_ingester/src/api/dapi/get_asset_batch.rs (2 hunks)
  • nft_ingester/src/api/dapi/search_assets.rs (4 hunks)
  • nft_ingester/src/api/util.rs (2 hunks)
  • nft_ingester/tests/api_tests.rs (72 hunks)
  • nft_ingester/tests/bubblegum_tests.rs (2 hunks)
  • nft_ingester/tests/decompress.rs (5 hunks)
  • nft_ingester/tests/dump_tests.rs (7 hunks)
  • postgre-client/src/asset_filter_client.rs (6 hunks)
  • postgre-client/src/storage_traits.rs (2 hunks)
  • postgre-client/tests/asset_filter_client_test.rs (10 hunks)
  • rocks-db/src/clients/asset_client.rs (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
postgre-client/src/storage_traits.rs (1)
postgre-client/src/asset_filter_client.rs (1)
  • get_grand_total (536-551)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build-base-image
  • GitHub Check: lint
  • GitHub Check: test
🔇 Additional comments (65)
nft_ingester/tests/dump_tests.rs (7)

7-7: Import change from options to DisplayOptions.

The import has been correctly updated to use the new DisplayOptions struct that's replacing the previous options types as part of aligning with the DAS reference implementation.


107-107: Option type replacement in get_asset_pubkeys_filtered call.

The code correctly uses the new DisplayOptions struct with the show_unverified_collections flag set to true, maintaining the same behavior as before while following the new type structure.


126-126: Updated import in mtg_441_tests module.

The import has been correctly updated to include DisplayOptions along with GetAsset, aligning with the type changes in the API.


212-215: Updated options field in GetAsset for authority_none_collection_authority_some test.

The code correctly wraps DisplayOptions in Some() and uses the spread operator to default all unspecified fields. This maintains the same behavior while adopting the new type structure.


247-250: Updated options field in GetAsset for authority_some_collection_authority_none test.

The options parameter has been properly migrated to the new type, maintaining consistency with the pattern used in other test cases.


281-284: Updated options field in GetAsset for authority_some_collection_authority_some test.

The migration to the new type structure has been implemented correctly, preserving the same functionality.


315-318: Updated options field in GetAsset for authority_none_collection_authority_none test.

All test cases now consistently use the new DisplayOptions type, completing the migration for this test module.

nft_ingester/src/api/dapi/get_asset_batch.rs (2)

3-3: Updated import to use DisplayOptions.

The import has been correctly changed to use the new unified DisplayOptions struct instead of the previous options type.


25-25:

Details

✅ Verification successful

Function parameter type updated from Options to DisplayOptions.

The parameter type has been updated correctly from Options to DisplayOptions, which is a breaking change (as indicated by the "!" in the PR title). This change aligns the function signature with the DAS reference implementation.

Verify that all call sites to this function have been updated to use the new parameter type:


🏁 Script executed:

#!/bin/bash
# Check for any remaining references to the old parameter type in call sites
rg -A 3 -B 3 "get_asset_batch" --type rust

Length of output: 8473


Review Update: Call Sites Verified for DisplayOptions Usage

The update from Options to DisplayOptions in the get_asset_batch function signature has been successfully verified. Our RG search confirmed that all call sites—in files such as nft_ingester/src/api/builder.rs, nft_ingester/src/api/api_impl.rs, and the integration tests—are now using the updated payload. In particular, the conversion from GetAssetBatchV0 (via .into()) has been correctly applied to construct the new GetAssetBatch parameter with DisplayOptions.

No lingering references to the old Options type were found. The breaking change aligns with the DAS reference implementation.

nft_ingester/src/api/dapi/get_asset.rs (1)

3-3: Updated import to use DisplayOptions.

The import has been correctly changed to use the new unified DisplayOptions struct instead of the previous options type.

nft_ingester/tests/decompress.rs (2)

16-16: Updated import to include DisplayOptions.

The import has been correctly updated to use the new DisplayOptions type from api_req_params.


285-288: Updated all GetAsset payload structures to use DisplayOptions.

All instances of the options field in the GetAsset payload have been correctly updated to use Some(DisplayOptions) with the show_unverified_collections flag set to true and other fields defaulted. This maintains consistent behavior across test cases while adopting the new type.

Also applies to: 376-379, 467-470, 558-561

nft_ingester/src/api/util.rs (3)

2-3: Imports updated to use DisplayOptions

The imports have been updated to replace the previous GetByMethodsOptions with the new DisplayOptions type, aligning with the refactoring effort to use a unified display options type.


9-9: API contract change: get_options() now returns DisplayOptions

The return type of the get_options() method in the ApiRequest trait has been changed from GetByMethodsOptions to DisplayOptions. This is a breaking change to the API contract that requires all implementers to be updated.


29-30: Implementation updated to handle Option

The implementation now uses unwrap_or_default() instead of the previous pattern which likely used .into() on a non-optional type. This properly handles the case where options might be None.

integration_tests/src/account_update_tests.rs (2)

4-4: Updated import to use DisplayOptions

The import statement has been updated to use DisplayOptions instead of Options, aligning with the API type changes.


129-129: Updated GetAsset to use Option

The options field in the GetAsset request is now wrapped in Some() and uses DisplayOptions instead of the previous direct usage of Options. This change accommodates the new optional options pattern.

nft_ingester/tests/bubblegum_tests.rs (2)

10-10: Updated import to use DisplayOptions

The import statement has been updated to use DisplayOptions instead of Options, aligning with the API type changes.


263-266: Updated GetAsset initialization to use Option

The options field in the GetAsset payload is now wrapped in Some() and uses DisplayOptions instead of the previous direct usage of Options. The functionality remains the same, with show_unverified_collections set to true and all other fields set to their defaults.

nft_ingester/src/api/dapi/asset.rs (3)

4-4: Updated import to use DisplayOptions

The import statement has been updated to use DisplayOptions instead of Options, aligning with the API type changes.


125-125: Updated parameter type to DisplayOptions

The parameter type for options in the asset_selected_maps_into_full_asset function has been changed from &Options to &DisplayOptions. This function still expects the same fields to exist in the new type.


164-164: Updated parameter type to DisplayOptions

The parameter type for options in the get_by_ids function has been changed from Options to DisplayOptions. The function logic appears to work with the same fields from the new type.

nft_ingester/src/api/dapi/search_assets.rs (4)

4-4: Import updated to use new DisplayOptions type.

The import has been correctly updated to use the new DisplayOptions type which replaces the previously used options types as part of the API refactoring.


42-42: Parameter type updated from GetByMethodsOptions to DisplayOptions.

The function signature has been correctly updated to use the new unified DisplayOptions type, aligning with the DAS reference implementation.


114-114: Parameter type updated from GetByMethodsOptions to DisplayOptions.

The function signature has been correctly updated to use the new unified DisplayOptions type, maintaining consistency with the refactoring approach.


173-173: Simplified options passing by removing type conversion.

The code has been updated to pass options.clone() directly instead of the previous options.clone().into(). This suggests the conversion is no longer needed since we're now using the same type throughout the call chain.

rocks-db/src/clients/asset_client.rs (2)

8-8: Import updated to use new DisplayOptions type.

The import has been correctly updated to use the new DisplayOptions type which replaces the previously used Options type.


157-157: Parameter type updated from &Options to &DisplayOptions.

The function signature has been correctly updated to use the new unified DisplayOptions type. The implementation logic and usage of the options object properties remain unchanged, indicating a clean type replacement.

postgre-client/tests/asset_filter_client_test.rs (3)

5-5: Import updated to use new DisplayOptions type.

The import has been correctly updated to use the new DisplayOptions type which replaces the previously used options types.


59-60: Updated test cases to use DisplayOptions instead of GetByMethodsOptions.

All test cases have been consistently updated to use the new DisplayOptions type with the same configuration as before, maintaining the functionality while aligning with the refactored API.

Also applies to: 128-129, 150-151, 177-178, 199-200, 224-225, 244-245, 304-305


365-370: Updated test case with proper DisplayOptions initialization.

The test case has been updated to use the new DisplayOptions type with the appropriate fields set, ensuring consistent behavior with the previous implementation while using the new unified type.

integration_tests/src/cnft_tests.rs (5)

3-3: Import updated to use new DisplayOptions type.

The import has been correctly updated to use the new DisplayOptions type which replaces the previously used Options type.


18-18: Function parameter type updated from Options to DisplayOptions.

The function signature has been correctly updated to use the new unified DisplayOptions type, ensuring consistency with the API changes.


27-27: Updated request structure to use optional DisplayOptions.

The GetAsset struct construction has been updated to wrap options in Some(), indicating that the options field in the GetAsset struct now uses Option<DisplayOptions> instead of directly using the options type. This change allows for explicit optional behavior.


71-71: Updated default options usage in test cases.

All test cases have been consistently updated to use DisplayOptions::default() instead of Options::default(), aligning with the refactored API while maintaining the same default behavior.

Also applies to: 105-105, 141-141, 250-250, 284-284, 321-321, 354-354, 387-387, 420-420, 452-452, 484-484, 517-517


549-555: Updated complex options initialization in test case.

The test case has been updated to use the new DisplayOptions type with the appropriate fields set, ensuring consistent behavior with the previous implementation. The ..Default::default() pattern is used correctly to set only the necessary fields while using defaults for the rest.

nft_ingester/tests/api_tests.rs (6)

109-116: Clean refactoring of SearchAssets options field.

The change from direct SearchAssetsOptions to Some(DisplayOptions) is consistent across all SearchAssets payloads in test cases, maintaining the existing functionality while aligning with the DAS reference implementation.

Also applies to: 142-146, 163-167, 184-188, 199-203, 220-224, 248-252, 270-274, 292-296, 314-318, 337-341, 359-363, 381-385, 403-407, 427-431


553-558: Consistent update of GetAsset options field.

All GetAsset payloads now use Some(DisplayOptions) instead of directly using Options, following the unified approach for option handling across API methods.

Also applies to: 678-682, 775-779, 897-901, 932-936, 1078-1082, 1090-1094, 1227-1231


1584-1586: Successfully updated GetTokenAccounts options field.

The GetTokenAccounts method already had options wrapped in Option<...>, so the change was limited to using DisplayOptions instead of the previous types. The splitting of owner_address and mint_address into separate lines is a good formatting improvement for readability.

Also applies to: 1599-1601, 1614-1616, 1729-1732, 1742-1745, 1755-1758, 1772-1776, 1823-1826, 1836-1839


1869-1873: Properly refactored options in asset query methods.

GetAssetsByOwner, GetAssetsByGroup, GetAssetsByCreator, and GetAssetsByAuthority methods all consistently use Some(DisplayOptions), maintaining API consistency.

Also applies to: 1904-1908, 1939-1943, 1974-1978


2008-2011: Updated assertion for refactored struct.

Test assertion updated to match the new structure with DisplayOptions, ensuring test validity is maintained through the refactoring.


4794-4794: Properly adjusted assertion to unwrap the now-optional field.

The assertion was correctly updated to unwrap the options field before accessing its properties, maintaining test correctness.

nft_ingester/src/api/api_impl.rs (4)

10-13: Imports look good and align with the new DisplayOptions usage.

No immediate issues spotted. Proceed.


332-332: Confirm that using a default DisplayOptions is intended.

Falling back to DisplayOptions::default() may implicitly disable certain features (like show_fungible or show_inscription). Ensure this behavior is correct.


371-371: Consistent default usage for batch retrieval.

Mirrors the single-asset approach. No concerns.


507-516: Field name alignment.

Using owner_address: owner and mint_address: mint follows the reference DAS naming. This destructuring is clear and consistent.

postgre-client/src/storage_traits.rs (2)

5-5: New import for DisplayOptions.

No issues with importing from api_req_params.


136-137: Grand total method signature extension.

Looks consistent with the overall refactoring.

entities/src/api_req_params.rs (10)

116-117: New optional options in GetAssetsByGroup.

Allowing displayOptions alias fosters flexible request structures.


132-133: Added options to GetAssetsByOwner.

Ensures consistent usage of DisplayOptions across endpoints.


145-145: Default annotation for cursor.

Provides a safe fallback if cursor is omitted.


154-155: Optional display options in GetAsset.

Great improvement for controlling output details on single asset retrieval.


161-162: Introduced options in GetAssetBatch.

Batch retrieval can now leverage display preferences.


189-190: Added options and default cursor for GetAssetsByCreator.

This aligns with other endpoints and ensures uniform usage.


202-203: displayOptions alias in GetAssetsByAuthority.

Consistent with other interface changes.


236-237: Owner and mint made optional in GetTokenAccounts.

Validation in get_token_accounts ensures at least one is present. Looks fine, but verify you gracefully handle absent owners or mints.


242-244: Allowing customizable display preferences.

Enables a broader range of behaviors when retrieving token accounts.


280-281: Optional DisplayOptions in SearchAssets.

Sufficient for controlling how search results are displayed.

postgre-client/src/asset_filter_client.rs (7)

5-5: LGTM: Import statement updated correctly

The import has been properly updated to use DisplayOptions from entities::api_req_params instead of the previous GetByMethodsOptions.


35-35: LGTM: Parameter type updated consistently

Function parameter type has been correctly updated from GetByMethodsOptions to DisplayOptions to align with the DAS reference implementation.


221-221: LGTM: Parameter type updated consistently

Function parameter type has been correctly updated from GetByMethodsOptions to DisplayOptions.


236-236: LGTM: Parameter type updated consistently

Function parameter type has been correctly updated from GetByMethodsOptions to DisplayOptions.


516-516: LGTM: Parameter type updated consistently

Function parameter type has been correctly updated from GetByMethodsOptions to DisplayOptions in the AssetPubkeyFilteredFetcher trait implementation.


539-539: LGTM: Parameter type updated consistently

Function parameter type has been correctly updated from GetByMethodsOptions to DisplayOptions in the get_grand_total method.


162-167:

Details

✅ Verification successful

Verify field compatibility between old and new types

The code continues to use the fields show_zero_balance and show_unverified_collections from the DisplayOptions struct, which suggests these fields exist in both the old and new types with the same semantics.

Also applies to: 375-378


🏁 Script executed:

#!/bin/bash
# Verify that the DisplayOptions struct contains the same fields used in this file
# and check how it differs from the previous GetByMethodsOptions struct

# Check the definition of DisplayOptions
echo "Checking DisplayOptions definition:"
rg -A 15 "struct DisplayOptions" --type rust

# Check the definition of the previous GetByMethodsOptions (might no longer exist)
echo "Checking GetByMethodsOptions definition (if still exists):"
rg -A 15 "struct GetByMethodsOptions" --type rust

# Look for any additional methods or default implementations for DisplayOptions
echo "Checking for DisplayOptions methods or implementations:"
rg "impl.*DisplayOptions" --type rust -A 5

Length of output: 1396


Field Compatibility Verified – No Changes Required

After verifying the definitions:

  • The new DisplayOptions (in entities/src/api_req_params.rs) correctly defines both show_zero_balance and show_unverified_collections.
  • The previous GetByMethodsOptions struct is no longer present, confirming that the migration to DisplayOptions has been completed.
  • The usage in postgre-client/src/asset_filter_client.rs (lines 162–167 and 375–378) correctly references the updated struct fields.

No further modifications are necessary.

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.

4 participants