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

Fix missing datums for toCardanoTxBody #167

Merged
merged 2 commits into from
Dec 6, 2021
Merged

Fix missing datums for toCardanoTxBody #167

merged 2 commits into from
Dec 6, 2021

Conversation

anton-k
Copy link
Contributor

@anton-k anton-k commented Dec 3, 2021

Fixes #139

@anton-k
Copy link
Contributor Author

anton-k commented Dec 3, 2021

Maybe the same thing should be applied to cardano-api, since the fix in the code that was copied from that repo,
if you can investiagate it I can provide the fix for cardano-api either.

@sjoerdvisscher
Copy link
Contributor

@anton-k The change has already been applied after we copied it! https://github.com/input-output-hk/cardano-node/blob/master/cardano-api/src/Cardano/Api/TxBody.hs#L2600

It looks like your nub is not necessary.

Just datum -> pure $ C.TxOutDatum C.ScriptDataInAlonzoEra (toScriptData $ P.getDatum datum)
Nothing -> toCardanoTxOutDatumHash datumHash

toScriptData :: P.BuiltinData -> C.ScriptData
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this the same as toCardanoScriptData?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I've fixed that

@anton-k
Copy link
Contributor Author

anton-k commented Dec 3, 2021

@anton-k The change has already been applied after we copied it! https://github.com/input-output-hk/cardano-node/blob/master/cardano-api/src/Cardano/Api/TxBody.hs#L2600

It looks like your nub is not necessary.

We need nub in case if we have several inputs with the same script, otherwise witness is going to be duplicated.
Also outputs can contain several datums which are the same.

@sjoerdvisscher
Copy link
Contributor

Thanks!

@anton-k
Copy link
Contributor Author

anton-k commented Dec 6, 2021

@sjoerdvisscher Thanks for merging!
It will be also cool to add nub to cardano-api version of it. In our project we had to create our own makeTransactionBody just for that reason. we had case where there are many inputs that are guarded by the same script and lead to duplication of the data and bloat in TX-size

@anton-k anton-k deleted the ak/fix-to-cardano-tx-body branch December 6, 2021 10:07
@sjoerdvisscher
Copy link
Contributor

@anton-k I agree, could you open an issue (or PR) against cardano-node?

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.

Strange behavior of toCardanoTxBody (missing datums)
2 participants