-
Notifications
You must be signed in to change notification settings - Fork 11
Reference inputs improvements #482
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
Merged
Merged
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
06c7b00
improve testing framework
mmontin 6b9c2c4
updating docs
mmontin f84d6d2
Update CHANGELOG.md
mmontin 909534b
initial refactoring of pretty modules
mmontin f0779de
finishing skeleton
mmontin 5adfc33
adding mockchain.hs in pretty
mmontin 87796ac
PrettyCookedL instead of PrettyCooked for skeletons
mmontin 3347de5
only instances in Skeleton
mmontin b54e353
type applying [DocCooked] properly
mmontin 7d0ebd5
Mockchain.hs revamped
mmontin fc7eca2
updating documentation
mmontin 0f46b08
changelog
mmontin 09b3f58
first mockchainst adjustment
mmontin d93759e
TxSkelOutDatum to DatumContent
mmontin 68c07b2
Merge branch 'main' into mm/improve-testing
mmontin 213d9c2
Merge branch 'main' into mm/improve-testing
mmontin d7d27e1
Merge branch 'main' into mm/pretty-printer
mmontin 8e830f1
Merge branch 'mm/pretty-printer' into mm/better-mockchainst
mmontin a7e5d30
fixing doc warnings
mmontin 1a8091d
fixing doc
mmontin 6f5207e
Merge branch 'main' into mm/improve-testing
mmontin 3fb54e4
Merge branch 'main' into mm/pretty-printer
mmontin 6dbead7
Merge branch 'mm/pretty-printer' into mm/better-mockchainst
mmontin e3af6f2
Merge branch 'main' into mm/improve-testing
mmontin 188b0db
nice merge
mmontin e29c1e8
rollback after merge error
mmontin fd127e6
unsafe helpers
mmontin f93d7a5
WIP
mmontin 46ffbd0
merging main into this
mmontin 15d1ff6
clarifying and simplifying errors
mmontin 356dbcc
more refinement of errors
mmontin 95d1834
Refactoring of outputs WIP
mmontin afc65c2
all tests pass
mmontin c416083
No more doc warnings
mmontin 2b9a8ad
bye bye datum and script hashes maps
mmontin de86e5b
updating MockChainReturn
mmontin d26ba47
adding doc comments
mmontin d99179f
some cleaning up
mmontin 48ae489
better printing
mmontin 6e1aed6
tests pass now, but need to investigate the ledger state update in CNE
mmontin 7e40d42
lighter init dist, printing of list of MockChainReturn
mmontin fe08b48
exploring the bug
mmontin dd92558
getting there
mmontin a8fae34
no more TxBodyError
mmontin 9861623
fix count of key witnesses
mmontin edc6cf3
Proper execution units computation
mmontin 7a23628
supporting proposals
mmontin 9c88b14
update flake and body
mmontin 6ecdc25
proposing scripts tests
mmontin 459aafe
handling withdrawals!
mmontin 21e9033
wallet withdrawals
mmontin 5ec2a18
removing usless comments, reorganizing Blockchain.hs
mmontin b4de056
cooked v6.0.0 release
mmontin fc8a6d5
Merge branch 'mm/release-cooked-v6' into mm/better-mockchainst
mmontin 0252026
ensuring the proper version of cardano-api
mmontin 4defaa4
add export in Proposal
mmontin 31beee1
full changelog
mmontin aa40aee
updating cheatsheet
mmontin ea7a700
updating the conway doc
mmontin f29b046
time
mmontin 1dd4663
fixing tests
mmontin eff2164
Merge branch 'main' into mm/better-mockchainst
mmontin e969d60
Merge branch 'mm/better-mockchainst' into mm/time-management
mmontin 0581638
updating to capi 10.16 with proper handling of ref input data hashes
mmontin 7db188e
proper handling of reference inputs in inputs
mmontin 7ad1f12
changelog updated
mmontin 5f50ea0
adding a test for reference scripts in inputs
mmontin e47bb6b
adding test, removing extra log event
mmontin 17a44d8
changelog
mmontin 21a83de
Merge branch 'mm/time-management' into mm/inputs-and-ref-inputs
mmontin 6af1006
haddock comments
mmontin 7c860fb
Update CHANGELOG.md
mmontin 00f3cd2
Merge branch 'main' into mm/time-management
mmontin 88c9c57
Merge branch 'mm/time-management' into mm/inputs-and-ref-inputs
mmontin 1256565
more documentation
mmontin ac9a54b
improving auto ref script algorithm
mmontin 90de9b4
Merge branch 'main' into mm/inputs-and-ref-inputs
mmontin 58e3019
Update src/Cooked/MockChain/GenerateTx/ReferenceInputs.hs
mmontin 81fb34b
update cabal.project and flake.lock (#483)
mmontin e020085
clarifying test on ref input in inputs
mmontin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- | This module allows the generation of Cardano reference inputs | ||
module Cooked.MockChain.GenerateTx.ReferenceInputs (toInsReference) where | ||
|
||
import Cardano.Api qualified as Cardano | ||
import Cooked.MockChain.BlockChain | ||
import Cooked.MockChain.GenerateTx.Common | ||
import Cooked.Skeleton | ||
import Data.Map qualified as Map | ||
import Data.Set qualified as Set | ||
import Ledger.Tx.CardanoAPI qualified as Ledger | ||
import PlutusLedgerApi.V3 qualified as Api | ||
|
||
-- | Takes a 'TxSkel' and generates the associated 'Cardano.TxInsReference' from | ||
-- its content. These reference inputs can be found in two places, either in | ||
-- direct reference inputs 'txSkelInsReference' or scattered in the various | ||
-- redeemers of the transaction, which can be gathered with | ||
-- 'txSkelInsReferenceInRedeemers'. | ||
toInsReference :: (MonadBlockChainBalancing m) => TxSkel -> m (Cardano.TxInsReference Cardano.BuildTx Cardano.ConwayEra) | ||
toInsReference skel = do | ||
-- As regular inputs can be used to hold scripts as if in reference inputs, we | ||
-- need to remove from the reference inputs stored in redeemers the ones that | ||
-- already appear in the inputs to avoid validation errors. | ||
let indirectReferenceInputs = txSkelInsReferenceInRedeemers skel | ||
redundantReferenceInputs = indirectReferenceInputs `Set.intersection` Map.keysSet (txSkelIns skel) | ||
refInputs = Set.toList (txSkelInsReference skel <> indirectReferenceInputs `Set.difference` redundantReferenceInputs) | ||
if null refInputs | ||
then return Cardano.TxInsReferenceNone | ||
else do | ||
cardanoRefInputs <- | ||
throwOnToCardanoError | ||
"toInsReference: Unable to translate reference inputs." | ||
(mapM Ledger.toCardanoTxIn refInputs) | ||
resolvedOutputs <- mapM unsafeDatumFromTxOutRef refInputs | ||
return $ | ||
Cardano.TxInsReference Cardano.BabbageEraOnwardsConway cardanoRefInputs $ | ||
Cardano.BuildTxWith $ | ||
Set.fromList | ||
[Ledger.toCardanoScriptData $ Api.toBuiltinData dat | TxSkelOutSomeDatum dat (Hashed _) <- resolvedOutputs] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.