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

Mint type: inner map should also allow duplicate keys? #687

Open
klntsky opened this issue Aug 30, 2024 · 2 comments
Open

Mint type: inner map should also allow duplicate keys? #687

klntsky opened this issue Aug 30, 2024 · 2 comments

Comments

@klntsky
Copy link

klntsky commented Aug 30, 2024

Consider the semantic difference between:

s1 -> [ t1 -> [ n1, n2 ] ]

and

s1 -> [ t1 -> [n1], t1 -> [n2]]

In CSL, Mint = Map ScriptHash MintsAssets, and MintsAssets = Array MintAssets, and MintAssets = Map AssetName Int.

It's impossible to encode the first variant AFAIK, although the CDDL allows it:

https://github.com/IntersectMBO/cardano-ledger/blob/43ea4aba860a58a335a71109eb13d146a960a71b/eras/conway/impl/cddl-files/conway.cddl#L201

@lisicky
Copy link
Contributor

lisicky commented Sep 20, 2024

Hey @klntsky! Why it is impossible?

@lisicky
Copy link
Contributor

lisicky commented Sep 20, 2024

CSL structs might not reflect CBOR structures as is, because we can add some backward compatibilities, api sugar, or to support "features" that is not documented but somehow exists.
In case of Mint struct you can easily serialize it as

{
  policy_id_1 :  { asset_name_1: 123, asset_name_2: 456 },
  policy_id_2 :  { asset_name_3: 123, asset_name_4: 456 }
}

or as

{
  policy_id_1 :  { asset_name_1: 123 },
  policy_id_1 :  { asset_name_2: 456 },
  policy_id_2 :  { asset_name_3: 123, asset_name_4: 456 }
}

Without any issues, but we don't recommend to use the second variant because the node will take into account only one of the duplicates. We add it because it's possible to have such strange mint on blockchain and we should able to deserialize it.

Just use MintsAssets with one MintAssets item. If you add multiple items into the MintsAssets you will have duplicated policy id's in a map

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

2 participants