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

Enable adding scripts with redeemers for withdrawals #308

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

nielstron
Copy link
Contributor

@nielstron nielstron commented Feb 13, 2024

This has a usecase in the "withdrawal trick", where only one withdrawal is executed per transaction, checking overall invariants, and all inputs/mints by the script just check that the withdrawal is present.

@nielstron
Copy link
Contributor Author

nielstron commented Feb 13, 2024

Note that ogmios v6 returns "withdraw:n" as the purpose for a withdrawal, so I changed the tag from "reward" to "withdraw". Not sure if ogmios v5 behaves differently.

Edit: removed from this PR

@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (8c3a12b) 83.42% compared to head (bb61a82) 83.09%.

Files Patch % Lines
pycardano/txbuilder.py 17.64% 13 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #308      +/-   ##
==========================================
- Coverage   83.42%   83.09%   -0.34%     
==========================================
  Files          28       28              
  Lines        3415     3431      +16     
  Branches      836      841       +5     
==========================================
+ Hits         2849     2851       +2     
- Misses        416      429      +13     
- Partials      150      151       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pycardano/plutus.py Outdated Show resolved Hide resolved
@nielstron
Copy link
Contributor Author

nielstron commented Feb 20, 2024

I have confirmed that the REWARD tag is actually called WITHDRAWAL in Ogmios 5 and WITHDRAW in Ogmios 6. The current naming would thus break both the chain contexts either way. Blockfrost also returns WITHDRAWAL.

@nielstron
Copy link
Contributor Author

Moreover there is only one place where the redeemer tag is actually used... which is within the transaction builder. So changing the value is most likely not breaking anything relevant. Anyways, I am open to move the change to a seperate PR

@cffls
Copy link
Collaborator

cffls commented Feb 20, 2024

Thanks for checking! I am fine with the name changing in future PR.

redeemer = self._inputs_to_redeemers[utxo]
redeemer.index = sorted_mint_policies.index(
script_hash(self._inputs_to_scripts[utxo])
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note I removed this case because AFAIK it is impossible to enter this part of the branch. Mint redeemers can only be present in mint scripts, not in inputs.

@nielstron nielstron merged commit 7cddd5d into Python-Cardano:main Feb 20, 2024
11 checks passed
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.

3 participants