diff --git a/src/GeniusYield/TxBuilder/Common.hs b/src/GeniusYield/TxBuilder/Common.hs index 19a985b3..08edb677 100644 --- a/src/GeniusYield/TxBuilder/Common.hs +++ b/src/GeniusYield/TxBuilder/Common.hs @@ -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 $