8000 add Appdata, linkedAppdata, displayOptions by MarkSackerberg · Pull Request #8 · metaplex-foundation/mpl-core-das · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add Appdata, linkedAppdata, displayOptions #8

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

Merged
merged 6 commits into from
Jun 27, 2025
Merged

Conversation

MarkSackerberg
Copy link
Contributor

This adds

  • appData
  • linkedAppData
  • displayOptions

Open questions:

  • is it fine how collection_metadata is handled as additional field in the top level of the asset?
  • Do we want to remove all displayOptions besides showCollectionMetadata since they don't seem to have an effect?

Copy link
coderabbitai bot commented Jun 4, 2025

Summary by CodeRabbit

  • New Features

    • Added support for an optional display option to include collection metadata (name, symbol, description, image) when retrieving assets and collections.
    • Enhanced asset and collection queries to validate display options, ensuring only supported options are accepted.
  • Bug Fixes

    • Improved error handling for unsupported display options during asset and collection retrieval.
  • Tests

    • Added tests for collection metadata retrieval, application data presence, and validation of supported and unsupported display options.
  • Chores

    • Updated minimum required versions for several dependencies.

Summary by CodeRabbit

  • New Features

    • Added support for an optional display option to include collection metadata when retrieving assets and collections.
    • Assets may now include a new field with collection metadata (name, symbol, description, image) when requested.
    • Enhanced support for application-specific data in asset details.
  • Bug Fixes

    • Improved validation to prevent unsupported display options when fetching assets and collections.
  • Chores

    • Updated peer and development dependencies to newer versions for improved compatibility.
  • Tests

    • Added tests to verify collection metadata retrieval, application data presence, and error handling for unsupported display options.

Walkthrough

The changes introduce support for a new displayOptions parameter in asset and collection retrieval functions, with validation to only allow the showCollectionMetadata option. Internal helpers are updated to handle new plugin types and collection metadata. Types and tests are extended to cover these enhancements and validate error handling for unsupported options.

Changes

File(s) Change Summary
package.json Upgraded peerDependencies and devDependencies for several @metaplex-foundation packages to higher versions.
src/das.ts Added and validated optional displayOptions parameter in asset/collection retrieval functions.
src/helpers.ts Extended helpers to support new plugin types and collection metadata extraction.
src/types.ts Added optional collection_metadata field to the DasExtra type.
test/das.test.ts Added tests for displayOptions validation, collection metadata, and plugin data retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant DAS_Module
    participant RPC_Layer

    Client->>DAS_Module: getAssetsByOwner({ owner, displayOptions })
    DAS_Module->>DAS_Module: validateDisplayOptions(displayOptions)
    alt Valid displayOptions
        DAS_Module->>RPC_Layer: searchAssets({ owner, displayOptions })
        RPC_Layer-->>DAS_Module: assetsWithCollectionMetadata
        DAS_Module-->>Client: assetsWithCollectionMetadata
    else Invalid displayOptions
        DAS_Module-->>Client: Error (unsupported display options)
    end
Loading
sequenceDiagram
    participant Client
    participant DAS_Module
    participant RPC_Layer

    Client->>DAS_Module: getAsset(asset, options, displayOptions)
    DAS_Module->>DAS_Module: validateDisplayOptions(displayOptions)
    alt Valid displayOptions
        DAS_Module->>RPC_Layer: getAsset(asset, options, displayOptions)
        RPC_Layer-->>DAS_Module: assetWithAppDatasAndCollectionMetadata
        DAS_Module-->>Client: assetWithAppDatasAndCollectionMetadata
    else Invalid displayOptions
        DAS_Module-->>Client: Error (unsupported display options)
    end
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/helpers.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "airbnb-base" to extend from. Please check that the name of the config is correct.

The config "airbnb-base" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 592367a and 86a3525.

📒 Files selected for processing (1)
  • src/helpers.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: MarkSackerberg
PR: metaplex-foundation/mpl-core-das#8
File: src/das.ts:139-145
Timestamp: 2025-06-15T00:43:15.791Z
Learning: In src/das.ts, the getAsset function intentionally maintains its original parameter order (context, asset, options, displayOptions) rather than using a single input object like other helpers, to avoid introducing breaking changes to existing code.
src/helpers.ts (1)
Learnt from: MarkSackerberg
PR: metaplex-foundation/mpl-core-das#8
File: src/das.ts:139-145
Timestamp: 2025-06-15T00:43:15.791Z
Learning: In src/das.ts, the getAsset function intentionally maintains its original parameter order (context, asset, options, displayOptions) rather than using a single input object like other helpers, to avoid introducing breaking changes to existing code.
✨ 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.

Copy link
vercel bot commented Jun 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mpl-core-das ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2025 0:11am

@MarkSackerberg MarkSackerberg marked this pull request as ready for review June 15, 2025 00:15
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: 6

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8813d80 and 592367a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • package.json (1 hunks)
  • src/das.ts (7 hunks)
  • src/helpers.ts (2 hunks)
  • src/types.ts (1 hunks)
  • test/das.test.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/das.ts (2)
src/constants.ts (1)
  • MPL_CORE_ASSET (1-1)
src/types.ts (4)
  • Pagination (7-10)
  • AssetOptions (12-14)
  • AssetResult (29-29)
  • CollectionResult (30-30)
🪛 Biome (1.9.4)
test/das.test.ts

[error] 313-313: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 314-314: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/das.ts

[error] 30-31: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

🔇 Additional comments (2)
src/helpers.ts (1)

302-363: DataSection / LinkedAppData conversion – correctness & maintainability

  • dataAuthority is assigned either an object or authority.type, causing a union of incompatible shapes.
    Always return a proper object to keep the adapter type sound.

  • offset for the LinkedAppData branch silently falls back to externalPlugin.data_offset ?? offset.
    If data_offset is 0, the ?? operator skips it – use ?? only for null/undefined checks or switch to ternary.

-  offset: externalPlugin.data_offset ? BigInt(externalPlugin.data_offset) : BigInt(offset),
+  offset: externalPlugin.data_offset !== undefined
+    ? BigInt(externalPlugin.data_offset)
+    : BigInt(offset),
package.json (1)

28-37: Dependency bumps – double-check breaking changes

Upgrading to @metaplex-foundation/digital-asset-standard-api@2.x and @metaplex-foundation/mpl-core@1.4.x introduces several breaking changes (e.g. renamed RPC args).
Ensure the library is built & the full test suite (including downstream consumers) still passes after the bump.

@MarkSackerberg
Copy link
Contributor Author

@danenbm please rereview.

@MarkSackerberg MarkSackerberg merged commit e2504cd into main Jun 27, 2025
5 checks passed
@MarkSackerberg MarkSackerberg deleted the displayOptions branch June 27, 2025 17:39
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
0