mirror of
https://github.com/FiloSpaTeam/plutus-pioneer-program.git
synced 2024-12-22 05:21:59 +01:00
pool formatting
This commit is contained in:
parent
30d6b92ac8
commit
c77890da1f
1 changed files with 17 additions and 5 deletions
|
@ -62,7 +62,7 @@ data Command =
|
|||
|
||||
readCommandIO :: IO Command
|
||||
readCommandIO = do
|
||||
putStrLn "Enter a command: Funds, Pools, Create amtA tnA amtB tnB"
|
||||
putStrLn "Enter a command: Funds, Pools, Create amtA tnA amtB tnB, Swap amtA tnA tnB"
|
||||
s <- getLine
|
||||
maybe readCommandIO return $ readMaybe s
|
||||
|
||||
|
@ -75,6 +75,12 @@ toCreateParams cs amtA tnA amtB tnB = US.CreateParams (toCoin cs tnA) (toCoin cs
|
|||
toSwapParams :: CurrencySymbol -> Integer -> Char -> Char -> US.SwapParams
|
||||
toSwapParams cs amtA tnA tnB = US.SwapParams (toCoin cs tnA) (toCoin cs tnB) (US.Amount amtA) (US.Amount 0)
|
||||
|
||||
showCoinHeader :: IO ()
|
||||
showCoinHeader = printf "\n currency symbol token name amount\n\n"
|
||||
|
||||
showCoin :: CurrencySymbol -> TokenName -> Integer -> IO ()
|
||||
showCoin cs tn amt = printf "%64s %66s %15d\n" (show cs) (show tn) amt
|
||||
|
||||
getFunds :: UUID -> IO ()
|
||||
getFunds cid = do
|
||||
callEndpoint cid "funds" ()
|
||||
|
@ -89,9 +95,8 @@ getFunds cid = do
|
|||
|
||||
showFunds :: Value -> IO ()
|
||||
showFunds v = do
|
||||
printf "\n currency symbol token name amount\n\n"
|
||||
forM_ (flattenValue v) $ \(cs, tn, amt) ->
|
||||
printf "%64s %66s %15d\n" (show cs) (show tn) amt
|
||||
showCoinHeader
|
||||
forM_ (flattenValue v) $ \(cs, tn, amt) -> showCoin cs tn amt
|
||||
printf "\n"
|
||||
|
||||
getPools :: UUID -> IO ()
|
||||
|
@ -103,9 +108,16 @@ getPools cid = do
|
|||
go = do
|
||||
e <- getStatus cid
|
||||
case e of
|
||||
Right (US.Pools ps) -> putStrLn $ "pools: " ++ show ps
|
||||
Right (US.Pools ps) -> showPools ps
|
||||
_ -> go
|
||||
|
||||
showPools :: [((US.Coin US.A, US.Amount US.A), (US.Coin US.B, US.Amount US.B))] -> IO ()
|
||||
showPools ps = do
|
||||
forM_ ps $ \((US.Coin (AssetClass (csA, tnA)), amtA), (US.Coin (AssetClass (csB, tnB)), amtB)) -> do
|
||||
showCoinHeader
|
||||
showCoin csA tnA (US.unAmount amtA)
|
||||
showCoin csB tnB (US.unAmount amtB)
|
||||
|
||||
createPool :: UUID -> US.CreateParams -> IO ()
|
||||
createPool cid cp = do
|
||||
callEndpoint cid "create" cp
|
||||
|
|
Loading…
Reference in a new issue