-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wallet.hs
40 lines (32 loc) · 1.43 KB
/
Wallet.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module DAppFlow.Wallet where
import Cardano.Wallet.Api.Types
import Wallet.Emulator.Types (WalletId)
import Transient.Move
import Transient.Logged (Raw(..))
import Transient.Move.Services
import Data.Aeson(decode)
import Data.ByteString.Lazy.Char8 as BS
import Control.Monad.IO.Class
getWallet :: WalletId -> Cloud ApiWallet
getWallet wid= do
Raw mr <- callService (walletHeader "GET /v2/wallets/$1") wid
case decode mr of
Just r -> return r
Nothing -> error $ "getWallet error for: " <> show wid
getWalletUtxoSnapshot :: WalletId -> Cloud ApiWalletUtxoSnapshot
getWalletUtxoSnapshot wid= callService (walletHeader "GET /v2/wallets/$1/utxo") wid
-- Raw mr <- callService (walletHeader "GET /v2/wallets/$1/utxo") wid
-- let r = decode mr
-- case r of
-- Just r -> return r
-- Nothing -> error $ "getWallet error for: " <> show wid
walletHeader req= [("service","Cardano wallet"),("type","HTTP")
,("nodehost","localhost")
,("nodeport","8090")
,("HTTPstr",req ++ " HTTP/1.1\r\nHost: $hostnode\r\n\r\n")]
-- callGoogle :: BS.ByteString -> Cloud BS.ByteString
-- callGoogle mod= callService google mod
-- google= [("service","google"),("type","HTTP")
-- ,("nodehost","www.google.com")
-- ,("nodeport","80")
-- ,("HTTPstr","GET /search?q=+$1+site:hackage.haskell.org HTTP/1.1\r\nHost: $hostnode\r\n\r\n" )]