Skip to content

Commit

Permalink
Fix review rework
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jul 16, 2021
1 parent 2120ffc commit 9a21b55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/core/src/Cardano/Wallet/Api/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3483,11 +3483,11 @@ instance EncodeAddress n => ToJSON (ApiMintBurnOperation n) where

instance DecodeAddress n => FromJSON (ApiMintBurnOperation n) where
parseJSON = Aeson.withObject "ApiMintBurnOperation" $ \o ->
case HM.toList o of
[("mint", mint)] -> ApiMint <$> parseJSON mint
[("burn", burn)] -> ApiBurn <$> parseJSON burn
[] -> fail "Must include a mint or burn operation"
_ -> fail "Each operation may be either a \"mint\" or a \"burn\"."
case HM.keys o of
["mint"] -> ApiMint <$> o .: "mint"
["burn"] -> ApiBurn <$> o .: "burn"
[] -> fail "Must include a \"mint\" or \"burn\" property."
_ -> fail "May be either a \"mint\" or a \"burn\"."

instance FromJSON ApiMintedBurnedInfo where
parseJSON = genericParseJSON defaultRecordTypeOptions
Expand Down
19 changes: 14 additions & 5 deletions lib/core/test/unit/Cardano/Wallet/Api/Malformed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@ instance Malformed (BodyParam (PostMintBurnAssetData ('Testnet pm))) where
}
}
}

}]
, "passphrase": #{nameTooLong}
}|]
Expand All @@ -2091,7 +2091,7 @@ instance Malformed (BodyParam (PostMintBurnAssetData ('Testnet pm))) where
}
}
}

}]
, "passphrase": #{nameTooLong}
}|]
Expand All @@ -2109,11 +2109,11 @@ instance Malformed (BodyParam (PostMintBurnAssetData ('Testnet pm))) where
}
}
}

}]
, "passphrase": #{nameTooLong}
}|]
, "Error in $['mint_burn'][0].operation: Each operation may either be a mint or a burn, not both"
, "Error in $['mint_burn'][0].operation: May be either a 'mint' or a 'burn'."
)
, ( [aesonQQ|
{ "mint_burn": [{ "monetary_policy_index": "0"
Expand All @@ -2126,6 +2126,15 @@ instance Malformed (BodyParam (PostMintBurnAssetData ('Testnet pm))) where
}]
, "passphrase": ""
}|]
, "Error in $['mint_burn'][0].operation: Encountered unexpected key(s): ['something_else']"
, "Error in $['mint_burn'][0].operation: May be either a 'mint' or a 'burn'."
)
, ( [aesonQQ|
{ "mint_burn": [{ "monetary_policy_index": "0"
, "asset_name": "deadbeef"
, "operation": {}
}]
, "passphrase": ""
}|]
, "Error in $['mint_burn'][0].operation: Must include a 'mint' or 'burn' property."
)
]

0 comments on commit 9a21b55

Please sign in to comment.