@@ -43,7 +43,6 @@ module Cardano.Wallet.API.V1.Types (
43
43
, getAccIndex
44
44
, mkAccountIndex
45
45
, AccountIndexError (.. )
46
- , renderAccountIndexError
47
46
-- * Addresses
48
47
, WalletAddress (.. )
49
48
, NewAddress (.. )
@@ -115,20 +114,17 @@ import Test.QuickCheck.Random (mkQCGen)
115
114
116
115
import Cardano.Wallet.API.Response.JSend (ResponseStatus (ErrorStatus ))
117
116
import Cardano.Wallet.API.Types.UnitOfMeasure (MeasuredIn (.. ), UnitOfMeasure (.. ))
118
- import Cardano.Wallet.API.V1.Errors (ToHttpErrorStatus (.. ), ToServantError (.. ),
119
- WalletError (.. ))
117
+ import Cardano.Wallet.API.V1.Errors (ToHttpErrorStatus (.. ), ToServantError (.. ))
120
118
import Cardano.Wallet.API.V1.Generic (gparseJsend , gtoJsend )
121
119
import Cardano.Wallet.Orphans.Aeson ()
122
120
import Cardano.Wallet.Util (showApiUtcTime )
123
121
import Pos.Aeson.Core ()
124
- import Pos.Arbitrary.Core ()
125
122
import Pos.Core (addressF )
126
123
import Pos.Crypto (decodeHash , hashHexF )
127
124
import Pos.Infra.Diffusion.Subscription.Status (SubscriptionStatus (.. ))
128
125
import Pos.Infra.Util.LogSafe (BuildableSafeGen (.. ), SecureLog (.. ), buildSafe ,
129
126
buildSafeList , buildSafeMaybe , deriveSafeBuildable ,
130
127
plainOrSecureF )
131
- import Pos.Util.BackupPhrase (BackupPhrase (.. ))
132
128
import Pos.Util.Mnemonic (Mnemonic )
133
129
import Pos.Wallet.Web.ClientTypes.Instances ()
134
130
@@ -890,12 +886,7 @@ instance Arbitrary WalletAddress where
890
886
newtype AccountIndex = AccountIndex { getAccIndex :: Word32 }
891
887
deriving (Show , Eq , Ord , Generic )
892
888
893
- instance Bounded AccountIndex where
894
- -- NOTE: minimum for hardened key. See https://iohk.myjetbrains.com/youtrack/issue/CO-309
895
- minBound = AccountIndex 2147483648
896
- maxBound = AccountIndex maxBound
897
-
898
- data AccountIndexError = AccountIndexError Word32
889
+ newtype AccountIndexError = AccountIndexError Word32
899
890
deriving (Eq , Show )
900
891
901
892
instance Buildable AccountIndexError where
@@ -911,26 +902,29 @@ mkAccountIndex index
911
902
| index >= getAccIndex minBound = Right $ AccountIndex index
912
903
| otherwise = Left $ AccountIndexError index
913
904
914
- renderAccountIndexError :: AccountIndexError -> Text
915
- renderAccountIndexError =
916
- sformat build
905
+ instance Bounded AccountIndex where
906
+ -- NOTE: minimum for hardened key. See https://iohk.myjetbrains.com/youtrack/issue/CO-309
907
+ minBound = AccountIndex 2147483648
908
+ maxBound = AccountIndex maxBound
917
909
918
910
instance ToJSON AccountIndex where
919
911
toJSON = toJSON . getAccIndex
920
912
921
913
instance FromJSON AccountIndex where
922
914
parseJSON =
923
- either ( fail . toString . sformat build) pure
924
- . mkAccountIndex
925
- <=< parseJSON
915
+ either fmtFail pure . mkAccountIndex <=< parseJSON
916
+ where
917
+ fmtFail = fail . toString . sformat build
926
918
927
919
instance Arbitrary AccountIndex where
928
- arbitrary = AccountIndex <$> choose (getAccIndex minBound , getAccIndex maxBound )
920
+ arbitrary =
921
+ AccountIndex <$> choose (getAccIndex minBound , getAccIndex maxBound )
929
922
930
923
deriveSafeBuildable ''AccountIndex
931
924
-- Nothing secret to redact for a AccountIndex.
932
925
instance BuildableSafeGen AccountIndex where
933
- buildSafeGen _ = bprint build . getAccIndex
926
+ buildSafeGen _ =
927
+ bprint build . getAccIndex
934
928
935
929
instance ToParamSchema AccountIndex where
936
930
toParamSchema _ = mempty
@@ -939,13 +933,17 @@ instance ToParamSchema AccountIndex where
939
933
& maximum_ .~ Just (fromIntegral $ getAccIndex maxBound )
940
934
941
935
instance ToSchema AccountIndex where
942
- declareNamedSchema = pure . paramSchemaToNamedSchema defaultSchemaOptions
936
+ declareNamedSchema =
937
+ pure . paramSchemaToNamedSchema defaultSchemaOptions
943
938
944
939
instance FromHttpApiData AccountIndex where
945
- parseQueryParam = first (sformat build) . mkAccountIndex <=< parseQueryParam
940
+ parseQueryParam =
941
+ first (sformat build) . mkAccountIndex <=< parseQueryParam
946
942
947
943
instance ToHttpApiData AccountIndex where
948
- toQueryParam = fromString . show . getAccIndex
944
+ toQueryParam =
945
+ fromString . show . getAccIndex
946
+
949
947
950
948
-- | A wallet 'Account'.
951
949
data Account = Account
0 commit comments