@@ -28,6 +28,7 @@ import Plutus.Contracts.Endpoints (BorrowParams(..), DepositParams(..), RepayPar
2828import Plutus.V1.Ledger.Crypto (PubKeyHash )
2929import Plutus.V1.Ledger.Value (AssetClass (..), TokenName (..), Value )
3030import View.FundsTable (fundsTable )
31+ import Utils.WithRemoteData (runRDWith )
3132
3233type State
3334 = { userContractId :: UserContractId
@@ -168,7 +169,7 @@ component =
168169 lift (AaveUser .revokeCollateral userContractId $ RevokeCollateralParams { rcpUnderlyingAsset: asset, rcpAmount: amount, rcpOnBehalfOf: walletPubKey })
169170 >>= either (throwError <<< show) (const <<< lift <<< H .raise $ SubmitSuccess )
170171 OnSubmitAmount operation (AmountForm.Submit { name, amount }) ->
171- runRD _submit <<< runExceptT
172+ void $ runRDWith _submit <<< runExceptT
172173 $ do
173174 { reserves } <- lift H .get
174175 case find (\r -> getAssetName r.asset == name) reserves of
@@ -177,56 +178,58 @@ component =
177178 lift $ handleAction (Deposit { amount, asset })
178179 { deposit } <- lift H .get
179180 RD .maybe
180- (throwError $ " Submit deposit failed: " <> show deposit )
181+ (throwError $ " Submit deposit failed" )
181182 (const <<< pure $ unit)
182183 deposit
183184 SubmitWithdraw -> do
184185 lift $ handleAction (Withdraw { amount, asset })
185186 { withdraw } <- lift H .get
186187 RD .maybe
187- (throwError $ " Submit withdraw failed: " <> show withdraw )
188+ (throwError $ " Submit withdraw failed" )
188189 (const <<< pure $ unit)
189190 withdraw
190191 SubmitBorrow -> do
191192 lift $ handleAction (Borrow { amount, asset })
192193 { borrow } <- lift H .get
193194 RD .maybe
194- (throwError $ " Submit borrow failed: " <> show borrow )
195+ (throwError $ " Submit borrow failed" )
195196 (const <<< pure $ unit)
196197 borrow
197198 SubmitRepay -> do
198199 lift $ handleAction (Repay { amount, asset })
199200 { repay } <- lift H .get
200201 RD .maybe
201- (throwError $ " Submit repay failed: " <> show repay )
202+ (throwError $ " Submit repay failed" )
202203 (const <<< pure $ unit)
203204 repay
204205 SubmitProvideCollateral -> do
205206 lift $ handleAction (ProvideCollateral { amount, asset })
206207 { provideCollateral } <- lift H .get
207208 RD .maybe
208- (throwError $ " Submit provideCollateral failed: " <> show provideCollateral )
209+ (throwError $ " Submit provideCollateral failed" )
209210 (const <<< pure $ unit)
210211 provideCollateral
211212 SubmitRevokeCollateral -> do
212213 lift $ handleAction (RevokeCollateral { amount, asset })
213214 { revokeCollateral } <- lift H .get
214215 RD .maybe
215- (throwError $ " Submit revokeCollateral failed: " <> show revokeCollateral )
216+ (throwError $ " Submit revokeCollateral failed" )
216217 (const <<< pure $ unit)
217218 revokeCollateral
218219 Nothing -> throwError " Asset name not found"
219-
220+
220221 render :: State -> H.ComponentHTML Action Slots m
221222 render state =
222223 HH .div_
223224 [ HH .div_ [ HH .h2_ [ HH .text " User funds" ], fundsTable state.userFunds ]
224225 , case state.submit of
225226 NotAsked -> HH .div_ []
226227 Loading -> HH .div_ []
227- Failure e -> HH .div_ [ HH .text $ " Error: " <> show e ]
228+ Failure e -> HH .h4_ [ HH .text e ]
228229 Success _ -> HH .div_ []
229- , HH .div_
230+ , case state.submit of
231+ Loading -> HH .div_ [ HH .text " Loading..." ]
232+ _ -> HH .div_
230233 $ mapWithIndex
231234 ( \index (Tuple title operation) ->
232235 HH .h2_
0 commit comments