-
Notifications
You must be signed in to change notification settings - Fork 18
Description
The TxBuilder interface as it exists is complete - it allows us to build all possible transactions - and flexible: It supports a variety of use cases such as inserting the index position of tx inputs into redeemers, computing good approximations of the lower boundaries of tx fees, coin selecting coins from UTxO sets with many different types of outputs).
The interface is not very ergononical however. Sometimes we have to repeat the same data multiple times, for example when spending several outputs from the same script address. Sometimes we need to dig deep into cardano-api types to accomplish simple tasks such as adding outputs with inline datums.
The following changes will greatly improve the usability of the transaction building API in sc-tools:
- Use
(TxIn, TxOut)as the "standard unit" for spending inputs. Currently we only require theTxInin a lot of places, but this just makes the API more opaque as we always have to provide the correctTxOutat the transaction balancing stage, if not sooner. We should keep track of aUTxOSetin theTxBuildertype, and extend this set whenever we add a new "spending" step to the builder. - The signature of "spending a script output" should only require the
(TxIn, TxOut)pair of the output and the redeemer. The decision whether to include the script as a reference script or as an attachment to the transaction should be taken separately. Then there should be a function "add reference scripts" that inspects the tx body content and adds all the reference scripts that it knows about if they are used in the transaction. - There should be a variant of "balanceTx" that uses the
MonadUtxoQuerytypeclass to obtain all the tx outputs that are available for balancing. We should also add more implementations ofMonadUtxoQuery, for example blockfrost.