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

JSON deserialization of on-chain-metadata fails for array types #3

Closed
sourcelib-stack opened this issue Feb 20, 2022 · 10 comments
Closed
Milestone

Comments

@sourcelib-stack
Copy link

Hi,

For some assets there are properties represented as arrays, example "images".
For those the assetService.getAsset(assetName); fails with this error:
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.lang.Stringfrom Array value (tokenJsonToken.START_ARRAY)

Example call: assetService.getAsset("4c9f7d6c24ba8e2b12f3269ac38d706025e39a50a524afe6eaf79d955665676769656d6174653036323031");

@bentaye
Copy link
Contributor

bentaye commented Mar 12, 2022

I just encountered the same issue so I had a look and grabbed the Json for that asset on the mainnet

Here it is:

{
    "asset": "4c9f7d6c24ba8e2b12f3269ac38d706025e39a50a524afe6eaf79d955665676769656d6174653036323031",
    "policy_id": "4c9f7d6c24ba8e2b12f3269ac38d706025e39a50a524afe6eaf79d95",
    "asset_name": "5665676769656d6174653036323031",
    "fingerprint": "asset1fkk7ch07h25jpzdwh3l9zp8ds7fz525qjakwe5",
    "quantity": "1",
    "initial_mint_tx_hash": "c8c8c8f7dba6f8bdf0a5727f63106037f65cdd00d36558469a87729a4c97ced6",
    "mint_or_burn_count": 1,
    "onchain_metadata": {
        "name": "Veggiemate06201",
        "image": "ipfs://QmXr96HxoMXPKJTca8aAhJjhpuhQDus3SboXYgkDPT6XAE",
        "body": "Hoodie",
        "eyes": "Squint",
        "head": "Sticker",
        "files": [
            {
                "src": "ipfs://QmXr96HxoMXPKJTca8aAhJjhpuhQDus3SboXYgkDPT6XAE",
                    "name": "Veggiemate06201",
                    "mediaType": "image/png"
            }
        ],
        "mouth": "Skull",
        "mediaType": "image/png",
        "typeClass": "Red Onion",
        "background": "Pink",
        "description": ""
    },
    "metadata": null
}

The error comes from the Asset class where onchainMetadata is defined as a Map<String, String>

    /**
     * On-chain metadata stored in the minting transaction under label 721,
     * community discussion around the standard ongoing at
     * https://github.com/cardano-foundation/CIPs/pull/85
     */
    private Map<String, String> onchainMetadata;

The value for the "files" field does not fit in there.
It should probably be a Map<String, Object>

As far as I can tell, there is no integration test for it. The only one I can find has no onchainMetadata.
I wanted to write one to reproduce the issue but I am not sure how to write it as it seems to require to have a similar asset on the testnet.

If someone could give us the policy/name of an asset on the testnet with such a non-String filed that would be great. Or create one.

@sourcelib-stack
Copy link
Author

sourcelib-stack commented Mar 13, 2022

Indeed Map<String, Object> worked just fine for me.

@satran004
Copy link
Collaborator

@sourcelib-stack Possible to create a PR for this issue ?

Otherwise, I will try to fix this.

@bentaye
Copy link
Contributor

bentaye commented Mar 14, 2022

@satran004 @sourcelib-stack I can have a try, I found some assets on the testnet that I can use to make an IT for it along with the fix

@bentaye
Copy link
Contributor

bentaye commented Mar 14, 2022

@satran004 I have it ready on a branch locally, I don't have the rights to push it.
Can you give me the required rights to make a PR?

@satran004
Copy link
Collaborator

@bentaye Did you try to fork the repo and create the PR ? By default, PR permission should be there for a fork.

@bentaye
Copy link
Contributor

bentaye commented Mar 14, 2022

@satran004 oh I see! PR is open now

@mmahut
Copy link
Member

mmahut commented Mar 28, 2022

Can this be closed?

@bentaye
Copy link
Contributor

bentaye commented Mar 28, 2022

Double check with @satran004 but AFAIAC I would say yes. And this one too #2 as it seems to me that it is the same problem

@satran004 satran004 added this to the 0.1.1 milestone Mar 28, 2022
@satran004
Copy link
Collaborator

This is already part of 0.1.1.

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

No branches or pull requests

4 participants