Skip to content

Commit

Permalink
Merge #2079
Browse files Browse the repository at this point in the history
2079: Improve lovelace parser failure in the cli r=Jimbo4350 a=Jimbo4350

Closes #2063 

Improved failure:
```
cabal exec cardano-cli -- shelley transaction build-raw --tx-in 91999ea21177b33ebe6b8690724a0c026d410a11ad7521caa350abdafa5394c3#0 --tx-out addr1v9wmu83pzajplrtpsq6tsqdgwr98x888trpmah2u0ezznsge7del3+18446744073709551616 --fee 1000 --ttl 1234 --out-file test
option --tx-out: Failed reading: 18446744073709551616 lovelace exceeds the Word64 upper bound
```

Co-authored-by: Jordan Millar <[email protected]>
  • Loading branch information
iohk-bors[bot] and Jimbo4350 authored Dec 8, 2020
2 parents fefe4b5 + 5594fe1 commit 7a709d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2360,7 +2360,11 @@ pProtocolVersion =
--

parseLovelace :: Atto.Parser Lovelace
parseLovelace = Lovelace <$> Atto.decimal
parseLovelace = do
i <- Atto.decimal
if i > toInteger (maxBound :: Word64)
then fail $ show i <> " lovelace exceeds the Word64 upper bound"
else return $ Lovelace i

parseAddressAny :: Atto.Parser AddressAny
parseAddressAny = do
Expand Down

0 comments on commit 7a709d7

Please sign in to comment.