@@ -27,8 +27,8 @@ import Pos.Util.Util (toAesonError)
27
27
-- | Bool-isomorphic flag indicating whether we're on testnet
28
28
-- or mainnet/staging.
29
29
data RequiresNetworkMagic
30
- = NMMustBeNothing
31
- | NMMustBeJust
30
+ = RequiresNoMagic
31
+ | RequiresMagic
32
32
deriving (Show , Eq , Generic )
33
33
34
34
instance NFData RequiresNetworkMagic
@@ -39,27 +39,27 @@ deriveSafeCopySimple 0 'base ''RequiresNetworkMagic
39
39
-- They should only be used from a parent instance which handles the
40
40
-- `requiresNetworkMagic` key.
41
41
instance A. ToJSON RequiresNetworkMagic where
42
- toJSON NMMustBeNothing = A. String " NMMustBeNothing "
43
- toJSON NMMustBeJust = A. String " NMMustBeJust "
42
+ toJSON RequiresNoMagic = A. String " RequiresNoMagic "
43
+ toJSON RequiresMagic = A. String " RequiresMagic "
44
44
45
45
instance A. FromJSON RequiresNetworkMagic where
46
46
parseJSON = A. withText " requiresNetworkMagic" $ toAesonError . \ case
47
- " NMMustBeNothing " -> Right NMMustBeNothing
48
- " NMMustBeJust " -> Right NMMustBeJust
47
+ " RequiresNoMagic " -> Right RequiresNoMagic
48
+ " RequiresMagic " -> Right RequiresMagic
49
49
other -> Left (" invalid value " <> show other <>
50
- " , acceptable values are NMMustBeNothing | NMMustBeJust " )
50
+ " , acceptable values are RequiresNoMagic | RequiresMagic " )
51
51
52
52
-- Canonical JSON instances
53
53
instance Monad m => ToJSON m RequiresNetworkMagic where
54
- toJSON NMMustBeNothing = pure (JSString " NMMustBeNothing " )
55
- toJSON NMMustBeJust = pure (JSString " NMMustBeJust " )
54
+ toJSON RequiresNoMagic = pure (JSString " RequiresNoMagic " )
55
+ toJSON RequiresMagic = pure (JSString " RequiresMagic " )
56
56
57
57
instance MonadError SchemaError m => FromJSON m RequiresNetworkMagic where
58
58
fromJSON = \ case
59
- (JSString " NMMustBeNothing " ) -> pure NMMustBeNothing
60
- (JSString " NMMustBeJust " ) -> pure NMMustBeJust
59
+ (JSString " RequiresNoMagic " ) -> pure RequiresNoMagic
60
+ (JSString " RequiresMagic " ) -> pure RequiresMagic
61
61
other ->
62
- expected " NMMustBeNothing | NMMustBeJust " (Just (show other))
62
+ expected " RequiresNoMagic | RequiresMagic " (Just (show other))
63
63
64
64
65
65
--------------------------------------------------------------------------------
@@ -96,12 +96,12 @@ instance A.ToJSON ProtocolMagic where
96
96
toJSON (ProtocolMagic (ProtocolMagicId ident) rnm) =
97
97
A. object [" pm" .= ident, " requiresNetworkMagic" .= rnm]
98
98
99
- -- Here we default to `NMMustBeJust ` (what testnets use) if only
99
+ -- Here we default to `RequiresMagic ` (what testnets use) if only
100
100
-- a ProtocolMagic identifier is provided.
101
101
instance A. FromJSON ProtocolMagic where
102
102
parseJSON v@ (A. Number _) = ProtocolMagic
103
103
<$> (ProtocolMagicId <$> A. parseJSON v)
104
- <*> pure NMMustBeJust
104
+ <*> pure RequiresMagic
105
105
parseJSON (A. Object o) = ProtocolMagic
106
106
<$> (ProtocolMagicId <$> o .: " pm" )
107
107
<*> o .: " requiresNetworkMagic"
@@ -128,20 +128,20 @@ instance Monad m => ToJSON m ProtocolMagic where
128
128
-- how this works.
129
129
toJSON (ProtocolMagic (ProtocolMagicId ident) _rnm) = toJSON ident
130
130
131
- -- Here we default to `NMMustBeJust ` (what testnets use) if only
131
+ -- Here we default to `RequiresMagic ` (what testnets use) if only
132
132
-- a ProtocolMagic identifier is provided.
133
133
instance MonadError SchemaError m => FromJSON m ProtocolMagic where
134
134
fromJSON = \ case
135
135
(JSNum n) -> pure (ProtocolMagic (ProtocolMagicId (fromIntegral n))
136
- NMMustBeJust )
136
+ RequiresMagic )
137
137
(JSObject dict) -> ProtocolMagic
138
138
<$> (ProtocolMagicId <$> expectLookup " pm: <int>" " pm" dict)
139
- <*> expectLookup " requiresNetworkMagic: <NMMustBeNothing | \
140
- \NMMustBeJust >"
139
+ <*> expectLookup " requiresNetworkMagic: <RequiresNoMagic | \
140
+ \RequiresMagic >"
141
141
" requiresNetworkMagic"
142
142
dict
143
143
other ->
144
- expected " NMMustBeNothing | NMMustBeJust " (Just (show other))
144
+ expected " RequiresNoMagic | RequiresMagic " (Just (show other))
145
145
146
146
expectLookup :: (MonadError SchemaError m , FromJSON m a )
147
147
=> String -> String -> [(String , JSValue )] -> m a
@@ -161,6 +161,6 @@ and the new format
161
161
```
162
162
protocolMagic:
163
163
pm: 12345678
164
- requiresNetworkMagic: NMMustBeNothing
164
+ requiresNetworkMagic: RequiresNoMagic
165
165
```
166
166
-}
0 commit comments