Skip to content
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

[Bug]: NFT metadata not fully parsed #56

Open
eddex opened this issue Oct 9, 2021 · 4 comments
Open

[Bug]: NFT metadata not fully parsed #56

eddex opened this issue Oct 9, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@eddex
Copy link
Contributor

eddex commented Oct 9, 2021

Contact Details

Discord: eddex#6808

What happened?

Blockfrost dotnet version: 0.0.4

Problem

When I get the Onchain_metadata of an NFT, blockfrost dotnet only returns the Image and the Name. I would like to be able to get the rest of the metadata too.

Details

The endpoint I use is /assets/<addet_id>. This endpoint returns all metadata:

"mint_or_burn_count": 1,
  "onchain_metadata": {
    "name": "NFT name",
    "image": "ipfs://QmRMETbpqSXqWd2bim6EhZ89uLaJsB3SZGW3zNWqNarDd8",
    "custom_prop1": "xyz",
    "custom_prop2": "abc",
    "mediaType": "image/png"
  },

Since C# is a statically typed language, the current solution of having a Onchain_metadata class in the library is not optimal. This calss only contains Image and Name. The rest of the data can't be retrieved.

Solution proposal

Make an overload of the IAssetService.AssetsAsync() method that allows to pass a generic type to the method. This type should be used to parse the Onchain_metadata.

Version

v0.0.1-alpha (default)

In what OS are you experiencing the problem?

Windows, Linux, MacOS, Docker

What version of dotnet are you using?

5.0.x

Relevant log output

No response

@tweakch
Copy link
Collaborator

tweakch commented Oct 9, 2021

Hi @eddex
thank you for raising this issue, its a very important one, and I will therefor not close it right away...

you are using the outdated IAssetService class. Consider using IAssetsService (notice the pluralized class name)... See migration guide for more information about the new services and how to migrate existing code

The new Service will return an AssetsResponse with JsonElement as type for OnchainMetadata.
so you can validate and convert this any way you want

IAssetsService service = serviceCollection.GetRequiredService<IAssetsService>();
var asset = await service.GetAssetsAsync("asset_id");
var json = asset.OnchainMetadata.GetRawText();
var model = JsonSerializer.Deserialize<YourModel>(json);

I really like the generic GetAssetsAsync<TMetadata>(string asset) and will add it in the next release

@eddex
Copy link
Contributor Author

eddex commented Oct 10, 2021

Ah ok, didn't realize there were 2 interfaces for the assets, thanks for clarifying!

@tweakch
Copy link
Collaborator

tweakch commented Oct 10, 2021

The UN-pluralized services will be removed in an upcoming release, i left them in as to not break existing implementations so that people have time to migrate.

@chriswill
Copy link

Also, the fields below are not exposed in the response:
"onchain_metadata_standard": "CIP68v1",
"onchain_metadata_extra": "d87980",

Also, for OnChainMetadata return type, I personally prefer a dynamic, since I really only care about name and image properties, and those are consistently there.

I just ended up writing my own return class and calling the service using Flurl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants