|
1 | 1 | module Main (main) where
|
2 | 2 |
|
3 |
| -import BotInterface.Wallet qualified as BW |
4 |
| -import Control.Monad (forever, replicateM_) |
5 |
| -import Data.Text (Text) |
6 |
| -import LocalCluster.Cluster (runUsingCluster) |
| 3 | +import Control.Monad (forever, replicateM_, void) |
| 4 | +import Control.Monad.IO.Class (liftIO) |
| 5 | +import Control.Monad.Reader (ask) |
| 6 | +import DSL ( |
| 7 | + ada, |
| 8 | + addSomeWallet, |
| 9 | + ledgerPaymentPkh, |
| 10 | + mkMainnetAddress, |
| 11 | + report, |
| 12 | + runContract, |
| 13 | + runUsingCluster, |
| 14 | + waitSeconds, |
| 15 | + ) |
| 16 | +import Data.Text (Text, unpack) |
| 17 | +import DebugContract.GetUtxos qualified as DebugContract |
| 18 | +import DebugContract.PayToWallet qualified as DebugContract |
| 19 | +import LocalCluster.Types (supportDir) |
7 | 20 | import System.Environment (setEnv)
|
8 | 21 | import Tools.DebugCli qualified as CLI
|
9 |
| -import Utils (ada, waitSeconds) |
10 |
| - |
11 |
| -import LocalCluster.Types (supportDir) |
12 | 22 |
|
13 | 23 | main :: IO ()
|
14 | 24 | main = do
|
15 | 25 | -- todo: maybe some better configuring procedure should be introduced
|
16 | 26 | setEnv "SHELLEY_TEST_DATA" "cluster-data/cardano-node-shelley"
|
17 | 27 | setEnv "NO_POOLS" "1"
|
18 |
| - setEnv "CARDANO_NODE_TRACING_MIN_SEVERITY" "Debug" |
19 | 28 |
|
20 |
| - runUsingCluster $ \cEnv -> do |
21 |
| - ws <- -- ? maybe it will be more ergonomic to get rid of `Ether` and just fail hard |
22 |
| - BW.usingEnv cEnv . fmap sequence . sequence $ |
23 |
| - [ BW.addSomeWallet (ada 101) |
24 |
| - , BW.addSomeWallet (ada 202) |
25 |
| - , BW.addSomeWallet (ada 303) |
26 |
| - ] |
27 |
| - putStrLn "\nDebug check:" |
28 |
| - putStrLn $ "Cluster dir: " <> show (supportDir cEnv) |
29 |
| - waitSeconds 2 |
30 |
| - either |
31 |
| - (error . ("Err: " <>) . show) |
32 |
| - (mapM_ (CLI.utxoAtAddress cEnv . BW.mkMainnetAddress)) ws |
33 |
| - putStrLn "Done. Debug awaiting - interrupt to exit" >> forever (waitSeconds 60) |
| 29 | + runUsingCluster $ do |
| 30 | + w1 <- -- ? maybe it will be more ergonomic to get rid of `Ether` and just fail hard |
| 31 | + -- as there is no reason to continue if wallet can't be set up |
| 32 | + addSomeWallet (ada 101) |
| 33 | + w2 <- addSomeWallet (ada 202) |
| 34 | + |
| 35 | + debugWallets (sequence [w1, w2]) --temporary, for debugging |
| 36 | + testW1 <- either (error . show) pure w1 |
| 37 | + runContract testW1 DebugContract.getUtxos |
| 38 | + >>= report |
| 39 | + runContract testW1 DebugContract.getUtxosThrowsErr |
| 40 | + >>= report |
| 41 | + runContract testW1 DebugContract.getUtxosThrowsEx |
| 42 | + >>= report |
| 43 | + |
| 44 | + testW2 <- either (error . show) pure w2 |
| 45 | + runContract testW1 (DebugContract.payTo (ledgerPaymentPkh testW2) 10_000_000) |
| 46 | + >>= report |
| 47 | + >> debugWallets (sequence [w1, w2]) |
34 | 48 |
|
35 |
| -testMnemonic :: [Text] |
36 |
| -testMnemonic = |
37 |
| - [ "radar" |
38 |
| - , "scare" |
39 |
| - , "sense" |
40 |
| - , "winner" |
41 |
| - , "little" |
42 |
| - , "jeans" |
43 |
| - , "blue" |
44 |
| - , "spell" |
45 |
| - , "mystery" |
46 |
| - , "sketch" |
47 |
| - , "omit" |
48 |
| - , "time" |
49 |
| - , "tiger" |
50 |
| - , "leave" |
51 |
| - , "load" |
52 |
| - ] |
| 49 | + liftIO $ putStrLn "Done. Debug awaiting - Enter to exit" >> void getLine |
| 50 | + where |
| 51 | + debugWallets ws = do |
| 52 | + cEnv <- ask |
| 53 | + liftIO $ putStrLn "\nDebug check:" |
| 54 | + liftIO $ putStrLn $ "Cluster dir: " <> show (supportDir cEnv) |
| 55 | + liftIO $ waitSeconds 2 |
| 56 | + either |
| 57 | + (error . ("Err: " <>) . show) |
| 58 | + (mapM_ (liftIO . CLI.utxoAtAddress cEnv . mkMainnetAddress)) |
| 59 | + ws |
0 commit comments