diff --git a/code/week10/.gitignore b/code/week10/.gitignore index 8aa6f56..1da8ff9 100644 --- a/code/week10/.gitignore +++ b/code/week10/.gitignore @@ -1,4 +1,5 @@ dist-newstyle/ +symbol.json uniswap.json W1.cid W2.cid diff --git a/code/week10/app/uniswap-client.hs b/code/week10/app/uniswap-client.hs index c8a8e8f..dce8977 100644 --- a/code/week10/app/uniswap-client.hs +++ b/code/week10/app/uniswap-client.hs @@ -16,7 +16,7 @@ import Data.Monoid (Last (..)) import Data.Proxy (Proxy (..)) import Data.Text (Text, pack) import Data.UUID -import Ledger.Value (flattenValue) +import Ledger.Value (CurrencySymbol, flattenValue) import Network.HTTP.Req import Plutus.Contracts.Uniswap (Uniswap, UserContractState (..)) import Plutus.PAB.Events.ContractInstanceState (PartiallyDecodedResponse (..)) @@ -34,14 +34,16 @@ main = do w <- Wallet . read . head <$> getArgs cid <- read <$> readFile (cidFile w) mus <- decode <$> LB.readFile "uniswap.json" - case mus of - Nothing -> putStrLn "invalid uniswap.json" >> exitFailure - Just us -> do + mcs <- decode <$> LB.readFile "symbol.json" + case (mus, mcs) of + (Just us, Just cs) -> do putStrLn $ "cid: " ++ show cid putStrLn $ "uniswap: " ++ show (us :: Uniswap) + putStrLn $ "symbol: " ++ show (cs :: CurrencySymbol) forever $ do getFunds cid threadDelay 1_000_000 + _ -> putStrLn "invalid uniswap.json and/or symbol.json" >> exitFailure getFunds :: UUID -> IO () getFunds uuid = handle h $ runReq defaultHttpConfig $ do diff --git a/code/week10/app/uniswap-pab.hs b/code/week10/app/uniswap-pab.hs index 202cc9c..36fb74e 100644 --- a/code/week10/app/uniswap-pab.hs +++ b/code/week10/app/uniswap-pab.hs @@ -50,6 +50,7 @@ main = void $ Simulator.runSimulationWith handlers $ do _ -> Nothing _ <- Simulator.waitUntilFinished cidInit + liftIO $ LB.writeFile "symbol.json" $ encode cs logString @(Builtin UniswapContracts) $ "Initialization finished. Minted: " ++ show cs cidStart <- Simulator.activateContract (Wallet 1) UniswapStart