@@ -160,16 +160,6 @@ balanceTx ::
160160 UnbalancedTx ->
161161 Eff effs BalanceTxResponse
162162balanceTx contractEnv unbalancedTx = do
163- -- TODO: Handle paging
164- -- (_, Page {pageItems}) <-
165- -- chainIndexQueryMany $
166- -- ChainIndexClient.getUtxoAtAddress $
167- -- addressCredential ownAddress
168- -- chainIndexTxOuts <- traverse (chainIndexQueryOne . ChainIndexClient.getTxOut) pageItems
169- -- let utxos =
170- -- Map.fromList $
171- -- catMaybes $ zipWith (\oref txout -> (,) <$> Just oref <*> txout) pageItems chainIndexTxOuts
172-
173163 eitherPreBalancedTx <-
174164 PreBalance. preBalanceTxIO @ w
175165 contractEnv. cePABConfig
@@ -214,25 +204,21 @@ writeBalancedTx contractEnv (Right tx) = do
214204
215205 pure $ maybe (WriteBalancedTxSuccess (Right tx)) (WriteBalancedTxFailed . OtherError ) result
216206
217- {- | Wait for at least n slots . The slot number only changes when a new block is appended to the chain
218- so it waits for at least one block
207+ {- | Wait at least until the given slot . The slot number only changes when a new block is appended
208+ to the chain so it waits for at least one block
219209-}
220210awaitSlot ::
221211 forall (w :: Type ) (effs :: [Type -> Type ]).
222212 Member (PABEffect w ) effs =>
223213 ContractEnvironment w ->
224214 Slot ->
225215 Eff effs Slot
226- awaitSlot contractEnv (Slot n) = do
227- tip <- CardanoCLI. queryTip @ w contractEnv. cePABConfig
228- waitNSlots' tip. slot
229- where
230- waitNSlots' refSlot = do
231- threadDelay @ w 10_000_000
232- tip' <- CardanoCLI. queryTip @ w contractEnv. cePABConfig
233- if tip'. slot < n
234- then waitNSlots' refSlot
235- else pure $ Slot tip'. slot
216+ awaitSlot contractEnv s@ (Slot n) = do
217+ threadDelay @ w 10_000_000
218+ tip' <- CardanoCLI. queryTip @ w contractEnv. cePABConfig
219+ if tip'. slot < n
220+ then awaitSlot contractEnv s
221+ else pure $ Slot tip'. slot
236222
237223currentSlot ::
238224 forall (w :: Type ) (effs :: [Type -> Type ]).
0 commit comments