-
-
Notifications
You must be signed in to change notification settings - Fork 76
Add add_native_script method to TransactionBuilder #255
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
Conversation
What is the delta of this to UPDATE: I just checked the diff and seems like native_scripts can be None. I think this is a good change. Does it make sense to check for uniqueness i.e. not add the script if it is contained in the list already? |
I believe it makes sense to check for uniqueness. You can make changes to the code if you want, it can probably be improved. I just think that such a method would be good, I was looking for it when trying to create my transaction and I saw that there isn't such a method. |
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #255 +/- ##
==========================================
- Coverage 84.97% 84.86% -0.11%
==========================================
Files 26 26
Lines 2982 2987 +5
Branches 714 715 +1
==========================================
+ Hits 2534 2535 +1
- Misses 336 340 +4
Partials 112 112
|
I think before we merge this definitely also needs a test case. On a seperate note I am wondering whether it makes sense to just add another parameter to "add_input_address" which lets you pass the native script. Or is there any other situation where you would want to plainly add a native script? |
Adding another parameter to "add_input_address" for the native script is a very good idea. I am not aware of any situation where it would be required to add the script separately. |
Thanks for the change. Maybe it was not documented clearly, but you can also use add_minting_script to add a native script. The script will get added to |
I tried using the
When building the transaction, I get the error:
This does not happen when I am using the commented part in my code instead of the I am happy with any solution that works instead of my workaround ( |
Thanks for the info. Could you provide the full stack trace of the error above? It seems a bug that could be fixed. |
This is the complete error:
|
Thanks for the info. This change should be able to fix the problem. Let me know if the solution works. If it does, I will merge the other fix and close this one. |
Closing this PR, since #257 fixed the issue. Feel free to reopen this otherwise. |
When creating a transaction spending funds from a script address, there is no obvious way of adding the script input to the transaction.
One way is to manually select the input UTxOs and then add them to the transaction using:
builder.add_script_input(utxo, native_script)
But if you want to let PyCardano select tin input UTxOs from the script address:
builder.add_input_address(script_address)
then you must manually add the native script like this:
builder.native_scripts = [native_script]
but you need to check if
builder.native_scripts
is not already containing native scripts.With this new method, it would me more straightforward:
builder.add_native_script(native_script)