Adding Metadata to Anchor

Some time ago, I created this pull request on Anchor, because I saw an opportunity to add Metadata parsing since the Anchor team was already adding Metadata program CPI calls. Initially, I thought it was going to be as simple as looking at one of the existing Candy Machine contracts and copying the code, but it turned out to be a bit more complicated than that.

The Challenge

It became clear that this was more of a communication task between different parties. As Armani noted, the initial implementation of the Metadata deserialization was not safe enough due to the lack of a series of verifications. This led me to reach out to the team at Metaplex for assistance with the implementation of the Metadata parsing.

The Solution

The outcome of this collaboration was the implementation of the safe_deserialize trait. This trait is now implemented by most of the Metadata program's accounts and is suitable for external use.

After several iterations with Sam (the creator of Metaboss), we arrived at a solution that was satisfactory for the time being. This allowed me to implement the Metadata in a more straightforward way.

The Learning

This experience taught me how to add Non-Anchor account deserialization to any Anchor project. This skill can be a powerful enabler for SDK development.

In conclusion, what started as a seemingly simple task turned into a valuable learning experience about collaboration in open-source development and the intricacies of safe data handling in blockchain applications.