Closed zmrocze closed 2 years ago
I've added the filtering in TxoSetAtAddress
, UtxoSetAtAddress
, UtxoSetWithCurrency
. Not sure about UtxoSetMembership
. Not sure how to test this meaningfully in mock.
the fail is the added test
Summary of this collateral mechanism work:
First before balancing any transaction we call handleCollateral
which works as follows:
ContractEnvironment
, if it is then proceed to balance the user's Tx
.ContractEnvironment
, then search for such utxo at user's wallet, if found then set that utxo as collateral in the ContractEnvironment
.Tx
, which is responsible for creating such collateral. After successfully creating and submitting the Tx
, set that utxo as collateral, then proceed to balance the user's Tx
.During balancing we filter out the collateral utxo, so that utxo can't be used as input for any transaction.
@samuelWilliams99 @mikekeke I have created an improved version of balanceTxIO
, here's the gist of the update: https://gist.github.com/IAmPara0x/4759b84add02dbf455c003545fbb98f4
This now enables us to use various constraints while balancing the transaction, this is very similar to how we create the transaction. Now we can have constraints like : balanceTxIO' [TxWithScript, TxWithSeperateChange]
, balanceTxIO' [TxWithScript]
, etc.
For eg: Now we can balance the collateral Tx like using the following constraint: balanceTxIO' [TxWithoutScript, TxWithSeperateChange]
.
And in future, if we need to add more constraints we can just create those types and append it to the existing list of constraints.
Let me know if this is an improvement and if I should implement it in this PR.
Updated the collateral handling mechanism as described here: https://github.com/mlabs-haskell/bot-plutus-interface/pull/124#issuecomment-1185896264.
Sorry, I was too late with my review, I had a few comments, maybe we could address these in a separate PR? @IAmPara0x
Yes, I will create the new PR soon, with the suggested changes
issue #89