Skip to content

Commit

Permalink
feat(#389): filter txIns from refIns
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabhxyz committed Jan 14, 2025
1 parent ca90658 commit e3fabc0
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/GeniusYield/TxBuilder/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -255,25 +255,27 @@ buildTxCore ss eh pp ps cstrat ownUtxoUpdateF addrs change reservedCollateral sk
gytxVotingProcedures' = case gytxVotingProcedures of GYTxSkeletonVotingProceduresNone -> mempty; GYTxSkeletonVotingProcedures vp -> vp
gytxProposalProcedures' = case gytxProposalProcedures of GYTxSkeletonProposalProceduresNone -> mempty; GYTxSkeletonProposalProcedures pps -> pps
refIns =
gyTxSkeletonRefInsToList gytxRefIns
<> [ r
| GYTxIn {gyTxInWitness = wit} <- gytxIns
, r <- case wit of
GYTxInWitnessScript (GYBuildPlutusScriptReference r _) _ _ -> [r]
GYTxInWitnessSimpleScript (GYBuildSimpleScriptReference r _) -> [r]
_anyOther -> []
]
<> [ r
| wit <- Map.keys gytxMint
, r <- case wit of
GYBuildPlutusScript (GYBuildPlutusScriptReference r _) -> [r]
GYBuildSimpleScript (GYBuildSimpleScriptReference r _) -> [r]
_anyOther -> []
]
<> [r | wdrl <- gytxWdrls, r <- maybeToList (extractReferenceFromWitness $ gyTxWdrlWitness wdrl)]
<> [r | cert <- gytxCerts, r <- maybeToList (gyTxCertWitness cert >>= extractReferenceFromWitness)]
<> [r | votingWit <- map fst (Map.elems gytxVotingProcedures'), r <- maybeToList (extractReferenceFromWitness votingWit)]
<> [r | propProc <- gytxProposalProcedures', r <- maybeToList (extractReferenceFromWitness $ snd propProc)]
-- We want to filter out the references that are already in the txIns.
filter (\oref -> all (\txIn -> gyTxInTxOutRef txIn /= oref) gytxIns) $
gyTxSkeletonRefInsToList gytxRefIns
<> [ r
| GYTxIn {gyTxInWitness = wit} <- gytxIns
, r <- case wit of
GYTxInWitnessScript (GYBuildPlutusScriptReference r _) _ _ -> [r]
GYTxInWitnessSimpleScript (GYBuildSimpleScriptReference r _) -> [r]
_anyOther -> []
]
<> [ r
| wit <- Map.keys gytxMint
, r <- case wit of
GYBuildPlutusScript (GYBuildPlutusScriptReference r _) -> [r]
GYBuildSimpleScript (GYBuildSimpleScriptReference r _) -> [r]
_anyOther -> []
]
<> [r | wdrl <- gytxWdrls, r <- maybeToList (extractReferenceFromWitness $ gyTxWdrlWitness wdrl)]
<> [r | cert <- gytxCerts, r <- maybeToList (gyTxCertWitness cert >>= extractReferenceFromWitness)]
<> [r | votingWit <- map fst (Map.elems gytxVotingProcedures'), r <- maybeToList (extractReferenceFromWitness votingWit)]
<> [r | propProc <- gytxProposalProcedures', r <- maybeToList (extractReferenceFromWitness $ snd propProc)]

allRefUtxos <-
utxosAtTxOutRefs $
Expand Down

0 comments on commit e3fabc0

Please sign in to comment.