2024-01-22 18:58:37 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE EmptyDataDecls #-}
|
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE GADTs #-}
|
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
{-# LANGUAGE TypeFamilies #-}
|
|
|
|
{-# LANGUAGE DerivingStrategies #-}
|
|
|
|
{-# LANGUAGE StandaloneDeriving #-}
|
|
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
{-# LANGUAGE DataKinds #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
2024-01-23 15:55:24 +00:00
|
|
|
{-# LANGUAGE TypeOperators #-}
|
2024-01-22 18:58:37 +00:00
|
|
|
|
2024-01-17 18:15:21 +00:00
|
|
|
module Zenith.DB where
|
2024-01-22 18:58:37 +00:00
|
|
|
|
2024-02-19 20:05:32 +00:00
|
|
|
import Control.Monad.IO.Class (liftIO)
|
2024-01-22 18:58:37 +00:00
|
|
|
import qualified Data.ByteString as BS
|
|
|
|
import qualified Data.Text as T
|
|
|
|
import Database.Persist
|
|
|
|
import Database.Persist.Sqlite
|
|
|
|
import Database.Persist.TH
|
2024-02-09 22:18:48 +00:00
|
|
|
import ZcashHaskell.Types (Phrase, ZcashNet)
|
|
|
|
|
|
|
|
derivePersistField "ZcashNet"
|
2024-01-22 18:58:37 +00:00
|
|
|
|
|
|
|
share
|
|
|
|
[mkPersist sqlSettings, mkMigrate "migrateAll"]
|
|
|
|
[persistLowerCase|
|
|
|
|
ZcashWallet
|
|
|
|
seedPhrase Phrase
|
|
|
|
spendingKey BS.ByteString
|
|
|
|
tPrivateKey BS.ByteString
|
|
|
|
birthdayHeight Int
|
|
|
|
name T.Text
|
2024-02-09 22:18:48 +00:00
|
|
|
network ZcashNet
|
2024-01-22 18:58:37 +00:00
|
|
|
deriving Show
|
|
|
|
|]
|
2024-02-19 20:05:32 +00:00
|
|
|
|
|
|
|
getWallets :: ZcashNet -> IO [Entity ZcashWallet]
|
|
|
|
getWallets n =
|
|
|
|
runSqlite "zenith.db" $ do
|
|
|
|
s <- selectList [ZcashWalletNetwork ==. n] []
|
|
|
|
liftIO $ return s
|