Skip to content

Conversation

kuksag
Copy link

@kuksag kuksag commented Jun 1, 2025

Overiew

This PR introduces interface required to implement NEP245 metadata extension

Token struct extension

In the specification it's stated:

A new attribute MUST be added to each Token struct:

type Token = {
  token_id: string,
+  token_metadata?: MTTokenMetadata,
+  base_metadata_id: string,
}

Which I haven't done on purpose.

Technically, it can be implemented using rust compile features to enable/disable code in case of implementing an extension.
But that's actually a breaking change with the code that has already implemented "core" standard.

On the other hand, having a token_id is sufficient to get related token_metadata and base_metadata_id (which forms MTTokenMetadataAll combined together) by calling mt_metadata_token_all.

Summary by CodeRabbit

  • New Features

    • Introduced support for NEP-245 multi-token metadata, including contract-level, base token, and individual token metadata structures.
    • Added public access to the metadata module for managing and retrieving multi-token metadata.
    • Enabled paginated listing and retrieval of metadata for multiple tokens.
    • Improved serialization and deserialization of UTC datetime fields in metadata.
  • Chores

    • Updated and refined dependencies to support new metadata features and serialization requirements.

@kuksag kuksag force-pushed the kuksag/nep245/metadata-ext branch from e82e1b3 to b3f86b2 Compare June 1, 2025 22:00
@kuksag
Copy link
Author

kuksag commented Jun 6, 2025

I haven't found borsh implementation for Datetime<Utc>, so I write a small wrapper. Let me know if that works for you.
Another option is to lift off #[near(serializers = [borsh])] requirements, but then anyway it will require every user to come up with some solution to store that data

@kuksag kuksag requested a review from BonelessImpl June 7, 2025 14:40
Copy link
Contributor

@BonelessImpl BonelessImpl left a comment

Choose a reason for hiding this comment

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

Besides the minor test issue, the interface looks alright. No implementation seems to be available.

@kuksag kuksag force-pushed the kuksag/nep245/metadata-ext branch 3 times, most recently from 1303b21 to 5c1c5d3 Compare June 10, 2025 17:04
@kuksag
Copy link
Author

kuksag commented Jun 10, 2025

@BonelessImpl I give up, I have no idea what to do with schemas (look at the failing build log). I've spent some time adding JsonSchema/trying to derive BorshSchema but it just doesn't work

@kuksag
Copy link
Author

kuksag commented Jun 10, 2025

nit: perhaps implementation of borsh de-serialization should be moved to borsh-utils

@kuksag kuksag force-pushed the kuksag/nep245/metadata-ext branch 2 times, most recently from cc01fb1 to f04a2f4 Compare June 13, 2025 17:05
@kuksag kuksag force-pushed the kuksag/nep245/metadata-ext branch from f04a2f4 to e688c94 Compare June 13, 2025 17:14
Copy link

coderabbitai bot commented Jun 18, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a new metadata module to the NEP-245 crate, implementing NEAR multi-token metadata standards with comprehensive data structures, traits, and serialization utilities. The metadata module is now publicly accessible. Additionally, the Cargo.toml file is updated to refine and expand dependencies, including new serialization and testing libraries.

Changes

File(s) Change Summary
nep245/Cargo.toml Expanded and refined dependencies; added new crates (borsh, chrono, serde_with, defuse-borsh-utils, schemars, hex) and enabled specific features. Introduced [dev-dependencies].
nep245/src/lib.rs Added public exposure for the new metadata module.
nep245/src/metadata.rs Introduced with NEP-245 metadata data structures, traits for metadata management/enumeration, and serialization utilities.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Contract
    participant MetadataStore

    Caller->>Contract: mt_metadata_contract()
    Contract-->>Caller: MTContractMetadata

    Caller->>Contract: mt_metadata_token_all(token_ids)
    Contract->>MetadataStore: Fetch base & token metadata for token_ids
    MetadataStore-->>Contract: Vec<Option<MTTokenMetadataAll>>
    Contract-->>Caller: Vec<Option<MTTokenMetadataAll>>

    Caller->>Contract: mt_tokens_base_metadata_all(from_index, limit)
    Contract->>MetadataStore: Paginate base metadata
    MetadataStore-->>Contract: Vec<MTBaseTokenMetadata>
    Contract-->>Caller: Vec<MTBaseTokenMetadata>
Loading

Poem

In the meadow of code, new metadata blooms,
Traits and structs now chase away the glooms.
With timestamps wrapped and tokens tall,
Serialization’s ready for one and all.
Dependencies gathered, the toolkit grows—
A rabbit hops where NEP-245 flows!
🐇✨


🪧 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.

@kuksag kuksag requested a review from BonelessImpl June 19, 2025 21:38
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.

3 participants