From ca6be91cbd334437b0268e7f2db82814713b4206 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 10 May 2019 08:51:58 +0200 Subject: [PATCH] Last estetic bits Concluding import fixes Typo fix --- lib/core/src/Cardano/Wallet/DB/Sqlite.hs | 9 +++- lib/core/src/Cardano/Wallet/DB/SqliteTypes.hs | 43 +++++++++++-------- .../test/unit/Data/Text/ClassSpec.hs | 6 +-- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/lib/core/src/Cardano/Wallet/DB/Sqlite.hs b/lib/core/src/Cardano/Wallet/DB/Sqlite.hs index eeaa96c4f2c..0c80fffbaae 100644 --- a/lib/core/src/Cardano/Wallet/DB/Sqlite.hs +++ b/lib/core/src/Cardano/Wallet/DB/Sqlite.hs @@ -22,6 +22,13 @@ import Data.Time.Clock import Data.Word ( Word32 ) import Database.Persist.TH + ( mkMigrate + , mkPersist + , mpsPrefixFields + , persistLowerCase + , share + , sqlSettings + ) import GHC.Generics ( Generic (..) ) @@ -62,7 +69,7 @@ PrivateKey sql=private_key -- blocks). -- -- TxMeta is specific to a wallet because multiple wallets may have the same --- transaction with different metdata values. The associated inputs and outputs +-- transaction with different metadata values. The associated inputs and outputs -- of the transaction are in the TxIn and TxOut tables. TxMeta txMetaTableTxId TxId sql=tx_id diff --git a/lib/core/src/Cardano/Wallet/DB/SqliteTypes.hs b/lib/core/src/Cardano/Wallet/DB/SqliteTypes.hs index f7774399bb6..907427c18a6 100644 --- a/lib/core/src/Cardano/Wallet/DB/SqliteTypes.hs +++ b/lib/core/src/Cardano/Wallet/DB/SqliteTypes.hs @@ -8,9 +8,29 @@ module Cardano.Wallet.DB.SqliteTypes where import Prelude +import Cardano.Wallet.Primitive.Types + ( Coin (..) + , Direction (..) + , Hash (..) + , SlotId (..) + , TxStatus (..) + , WalletId (..) + , WalletState (..) + , flatSlot + , fromFlatSlot + , isValidCoin + ) import Control.Monad ( (>=>) ) import Data.Aeson + ( FromJSON (..) + , ToJSON (..) + , Value (..) + , defaultOptions + , genericParseJSON + , genericToJSON + , withText + ) import Data.Aeson.Types ( Parser ) import Data.Bifunctor @@ -35,23 +55,12 @@ import Database.Persist.Sqlite import GHC.Generics ( Generic ) import Web.HttpApiData + ( FromHttpApiData (..), ToHttpApiData (..) ) import Web.PathPieces + ( PathPiece (..) ) import qualified Data.Text as T -import Cardano.Wallet.Primitive.Types - ( Coin (..) - , Direction (..) - , Hash (..) - , SlotId (..) - , TxStatus (..) - , WalletId (..) - , WalletState (..) - , flatSlot - , fromFlatSlot - , isValidCoin - ) - ---------------------------------------------------------------------------- -- Helper functions @@ -117,7 +126,6 @@ instance PathPiece WalletId where fromPathPiece = fromTextMaybe toPathPiece = toText - ---------------------------------------------------------------------------- -- AddressScheme @@ -137,7 +145,7 @@ instance FromText AddressScheme where "any" -> Right Any _ -> Left . TextDecodingError $ show txt - <> " is neither \"sequential\", \"random\", nor \"any\"" + <> " is neither \"sequential\", \"random\", nor \"any\"" instance ToText AddressScheme where toText Sequential = "sequential" @@ -231,8 +239,9 @@ instance PersistFieldSql TxStatus where -- Coin mkCoin :: Word64 -> Either Text Coin -mkCoin n | isValidCoin c = Right c - | otherwise = Left . T.pack $ "not a valid coin: " <> show n +mkCoin n + | isValidCoin c = Right c + | otherwise = Left . T.pack $ "not a valid coin: " <> show n where c = Coin n instance PersistField Coin where diff --git a/lib/text-class/test/unit/Data/Text/ClassSpec.hs b/lib/text-class/test/unit/Data/Text/ClassSpec.hs index 5633dc91e86..829dc0a801c 100644 --- a/lib/text-class/test/unit/Data/Text/ClassSpec.hs +++ b/lib/text-class/test/unit/Data/Text/ClassSpec.hs @@ -54,9 +54,9 @@ spec = do $ property $ \(i :: Int) -> (fromText . toText) i === pure i it "fromText ~ fromTextMaybe" $ property $ \(Digits t) -> - classify (isNothing (fromTextMaybe @Int t)) "invalid" $ - classify ((compare 0 <$> fromTextMaybe @Int t) == Just GT) "valid negative" $ - toList (fromTextMaybe @Int t) === toList (fromText t) + classify (isNothing (fromTextMaybe @Int t)) "invalid" $ + classify ((compare 0 <$> fromTextMaybe @Int t) == Just GT) "valid negative" $ + toList (fromTextMaybe @Int t) === toList (fromText t) describe "Text" $ do it "fromText \"patate\"" $