Skip to content

Conversation

@SebastienGllmt
Copy link
Contributor

Currently a few places in cardano-serialization-lib hardcode that no data hash is present in outputs which can lead to the incorrect minimum ADA amount being calculated.

This PR fixes these by properly tracking data hash in the tx builder.

However, I ran into a problem: the tx builder currently has a combinatorial explosion of different functions for adding outputs. Notably,

  • add_output_amount
  • add_output_coin
  • add_output_asset_and_min_required_coin
  • add_mint_asset_and_output
  • add_mint_asset_and_output_min_required_coin

We can't just add a new optional parameter to all these functions because WASM doesn't like Option, so the naive solution would be to double the number of functions which isn't acceptable either.

To tackle this, I instead created an TransactionOutputBuilder so that it's easier to create plain TransactionOutput objects based on certain requirements. This simplifies the txbuilder code and also makes it easier to deal with TransactionOutput creation on the JS-side as well

@SebastienGllmt SebastienGllmt added the bug Something isn't working label Dec 22, 2021
@SebastienGllmt SebastienGllmt self-assigned this Dec 22, 2021
@SebastienGllmt
Copy link
Contributor Author

SebastienGllmt commented Dec 22, 2021

Note: this will soft-conflict with the following PR because it hardcodes false in the tx builder

Copy link
Contributor

@rooooooooob rooooooooob left a comment

Choose a reason for hiding this comment

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

LGTM although @vsubhuman should check it over too since he was the one who added these convenience functions to begin with and his PR #273 touches some of this code (although from what I can see it should be fine since that PR doesn't change how the output is added for the mint+output convenience setters.)

@vsubhuman vsubhuman added this to the 10.0.0 milestone Feb 1, 2022
Copy link
Member

@vsubhuman vsubhuman left a comment

Choose a reason for hiding this comment

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

Great change, thank you, Seba!

Copy link
Member

@vsubhuman vsubhuman left a comment

Choose a reason for hiding this comment

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

/check

@vsubhuman vsubhuman merged commit 3c958de into master Feb 5, 2022
@vsubhuman vsubhuman deleted the simplify-txbuilder-outputs branch February 5, 2022 20:18
@vsubhuman vsubhuman mentioned this pull request Feb 6, 2022
40 tasks
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

Successfully merging this pull request may close these issues.

4 participants