@@ -43,8 +43,10 @@ import Convex.MockChain (applyTransaction, initialState)
4343import Convex.NodeParams (NodeParams )
4444import Convex.Wallet (Wallet )
4545import Convex.Wallet qualified as Wallet
46+ import Convex.Wallet.MockWallet (mockWallets )
4647import Data.ByteString.Short qualified as SBS
4748import Data.Either (isRight )
49+ import Data.Foldable (foldrM )
4850import Data.Map qualified as Map
4951import Data.Maybe (listToMaybe )
5052import Data.Maybe.Strict
@@ -255,6 +257,9 @@ txSigners (Tx _ wits) = [toHash wit | ShelleyKeyWitness _ (WitVKey wit _) <- wit
255257 . hashKey
256258 . coerceKeyRole
257259
260+ mockWalletHashes :: [(Hash PaymentKey , Wallet )]
261+ mockWalletHashes = map (\ w -> (Wallet. verificationKeyHash w, w)) mockWallets
262+
258263-- | Get the required signers from the transaction body (not witnesses).
259264txRequiredSigners :: Tx Era -> [Hash PaymentKey ]
260265txRequiredSigners (Tx (ShelleyTxBody _ body _ _ _ _) _) =
@@ -494,7 +499,11 @@ rebalanceAndSign wallet tx utxo = do
494499 -- Re-sign (strip old signatures and add new one)
495500 let Tx finalBody _ = finalTx
496501 unsignedTx = makeSignedTransaction [] finalBody
497- pure $ Right $ Wallet. signTx wallet unsignedTx
502+ signers = txSigners tx
503+ sign hash tx' = case lookup hash mockWalletHashes of
504+ Just w -> Right $ Wallet. signTx w tx'
505+ Nothing -> Left " Transaction was signed by an unknown wallet"
506+ pure $ foldrM sign unsignedTx signers
498507
499508{- | Update execution units in a transaction by evaluating all scripts.
500509
@@ -635,8 +644,8 @@ setTxOutputsList newOuts (Tx (ShelleyTxBody era body scripts scriptData auxData
635644 let newOutsSeq =
636645 Seq. fromList
637646 [ CBOR. mkSized
638- (Ledger. eraProtVerLow @ LedgerEra )
639- (toShelleyTxOut shelleyBasedEra (toCtxUTxOTxOut out))
647+ (Ledger. eraProtVerLow @ LedgerEra )
648+ (toShelleyTxOut shelleyBasedEra (toCtxUTxOTxOut out))
640649 | out <- newOuts
641650 ]
642651 body' = body{Conway. ctbOutputs = newOutsSeq}
0 commit comments