Skip to content

Commit

Permalink
Use method for encryption method in ApiEncryptMetadata. (#4589)
Browse files Browse the repository at this point in the history
This PR changes the name for the encryption method field for
`ApiEncryptMetadata` from `enc` to `method`.

## Justification

- In the context of the `cardano-wallet` HTTP API, it's idiomatic to use
complete words instead of shortenings such as `enc`.
- The name `method` is consistent with the field type
`ApiEncryptMetadataMethod`.
- The name `method` is (arguably) more self-documenting than `enc`.

## Issue

ADP-322
  • Loading branch information
jonathanknowles authored May 16, 2024
2 parents 5d55509 + c2b329f commit fbfb5a7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/api/src/Cardano/Wallet/Api/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ data ApiEncryptMetadataMethod = Basic

data ApiEncryptMetadata = ApiEncryptMetadata
{ passphrase :: ApiT (Passphrase "lenient")
, enc :: Maybe ApiEncryptMetadataMethod
, method :: Maybe ApiEncryptMetadataMethod
}
deriving (Eq, Generic, Show)
deriving (FromJSON, ToJSON) via DefaultRecord ApiEncryptMetadata
Expand Down
16 changes: 8 additions & 8 deletions lib/unit/test/data/Cardano/Wallet/Api/ApiEncryptMetadata.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ spec = do
it "short msg - no salt" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand Down Expand Up @@ -1243,7 +1243,7 @@ spec = do
it "long msg - no salt" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand Down Expand Up @@ -1291,7 +1291,7 @@ spec = do
it "cip msg - no salt" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand Down Expand Up @@ -1340,7 +1340,7 @@ spec = do
it "short msg - salted" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand Down Expand Up @@ -1385,7 +1385,7 @@ spec = do
it "long msg - salted" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand Down Expand Up @@ -1431,7 +1431,7 @@ spec = do
it "cip msg - salted" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand Down Expand Up @@ -1479,7 +1479,7 @@ spec = do
it "msg wrong label - no salt" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand All @@ -1505,7 +1505,7 @@ spec = do
it "msg without 'msg field' - no salt" $ do
let apiEncrypt = ApiEncryptMetadata
{ passphrase = ApiT $ Passphrase "cardano"
, enc = Nothing
, method = Nothing
}
schemaBefore =
TxMetadataWithSchema TxMetadataNoSchema $
Expand Down Expand Up @@ -3555,10 +3555,10 @@ class GetPath api where
getPath :: Proxy api -> (StdMethod, String)

instance (Method m) => GetPath (Verb m s ct a) where
getPath _ = (method (Proxy @m), "")
getPath _ = (stdMethod (Proxy @m), "")

instance (Method m) => GetPath (NoContentVerb m) where
getPath _ = (method (Proxy @m), "")
getPath _ = (stdMethod (Proxy @m), "")

instance (KnownSymbol path, GetPath sub) => GetPath (path :> sub) where
getPath _ =
Expand Down Expand Up @@ -3591,13 +3591,13 @@ instance GetPath sub => GetPath (Header' opts name ty :> sub) where
-- A way to demote 'StdMethod' back to the world of values. Servant provides a
-- 'reflectMethod' that does just that, but demote types to raw 'ByteString' for
-- an unknown reason :/
instance Method 'GET where method _ = GET
instance Method 'POST where method _ = POST
instance Method 'PUT where method _ = PUT
instance Method 'DELETE where method _ = DELETE
instance Method 'PATCH where method _ = PATCH
instance Method 'GET where stdMethod _ = GET
instance Method 'POST where stdMethod _ = POST
instance Method 'PUT where stdMethod _ = PUT
instance Method 'DELETE where stdMethod _ = DELETE
instance Method 'PATCH where stdMethod _ = PATCH
class Method (m :: StdMethod) where
method :: Proxy m -> StdMethod
stdMethod :: Proxy m -> StdMethod

{-------------------------------------------------------------------------------
Generating Golden Test Vectors For Address Encoding
Expand Down
2 changes: 1 addition & 1 deletion specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ x-encryptMetadata: &encryptMetadata
required:
- passphrase
properties:
enc: *encryptionMethod
method: *encryptionMethod
passphrase: *lenientPassphrase

x-transactionTTL: &transactionTTL
Expand Down

0 comments on commit fbfb5a7

Please sign in to comment.