Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #295

Merged
merged 6 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix a bug in correctly accounting for parsed events.

## 7.0.0

- Support node version 7 and protocol version 7.
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ To determine the exact path to the `libffi` include directory, run the following
pkg-config --cflags libffi
```

## Test

``` sh
stack build --test
```

## Format

``` sh
fourmolu -i $(git ls-files '*.hs')
```

## Usage

Run using `stack run concordium-client -- [BACKEND] COMMAND [ARGS...]`, where
Expand Down
33 changes: 17 additions & 16 deletions src/Concordium/Client/Output.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import Data.Bool
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BSL
import qualified Data.ByteString.Short as BSS
import Data.Either (isLeft)
import Data.Either (isRight)
import Data.Functor
import Data.List (foldl', intercalate, nub, partition, sortOn)
import qualified Data.Map.Strict as Map
Expand Down Expand Up @@ -203,16 +203,15 @@ printAccountInfo addr a verbose showEncrypted mEncKey = do
0 -> []
tot ->
(printf "Release schedule: total %s" (showCcd tot))
: ( map
( \Types.ScheduledRelease{..} ->
printf
" %s: %s scheduled by the transactions: %s."
(showTimeFormatted (Time.timestampToUTCTime releaseTimestamp))
(showCcd releaseAmount)
(intercalate ", " $ map show releaseTransactions)
)
(Types.releaseSchedule $ Types.aiAccountReleaseSchedule a)
)
: map
( \Types.ScheduledRelease{..} ->
printf
" %s: %s scheduled by the transactions: %s."
(showTimeFormatted (Time.timestampToUTCTime releaseTimestamp))
(showCcd releaseAmount)
(intercalate ", " $ map show releaseTransactions)
)
(Types.releaseSchedule $ Types.aiAccountReleaseSchedule a)
++ [ printf "Nonce: %s" (show $ Types.aiAccountNonce a),
printf "Encryption public key: %s" (show $ Types.aiAccountEncryptionKey a),
""
Expand Down Expand Up @@ -312,7 +311,7 @@ printAccountInfo addr a verbose showEncrypted mEncKey = do

-- | Print a versioned credential. This only prints the credential value, and not the
-- associated version.
printVersionedCred :: (Show credTy) => (IDTypes.CredentialIndex, (Versioned (IDTypes.AccountCredential' credTy))) -> Printer
printVersionedCred :: (Show credTy) => (IDTypes.CredentialIndex, Versioned (IDTypes.AccountCredential' credTy)) -> Printer
printVersionedCred (ci, vc) = printCred ci (vValue vc)

-- | Print the registration id, expiry date, and revealed attributes of a credential.
Expand Down Expand Up @@ -912,14 +911,16 @@ showEvent verbose ciM = \case
showLoggedEvents :: [Wasm.ContractEvent] -> String
showLoggedEvents [] = "No contract events were emitted."
showLoggedEvents evs =
[i|#{length evs} contract events were emitted|]
[i|#{length evs} contract #{if length evs > 1 then "events were" else ("event was" :: String)} emitted|]
<> ( if isNothing eventSchemaM
then [i| but no event schema was provided nor found in the contract module. |]
else [i|, of which #{length $ filter isLeft $ map showContractEvent evs} were succesfully parsed. |]
else [i|, of which #{noOfParsedEvents} #{if noOfParsedEvents > 1 then "were" else ("was" :: String)} successfully parsed. |]
rasmus-kirk marked this conversation as resolved.
Show resolved Hide resolved
)
<> [i|Got:\n|]
<> intercalate "\n" (map fromEither (map showContractEvent evs))
<> intercalate "\n" (map (fromEither . showContractEvent) evs)
where
noOfParsedEvents :: Int
noOfParsedEvents = length $ filter isRight $ map showContractEvent evs
fromEither :: Either a a -> a
fromEither (Left v) = v
fromEither (Right v) = v
Expand All @@ -928,7 +929,7 @@ showEvent verbose ciM = \case
eventSchemaM = getEventSchema =<< ciM
-- Show a string representation of the contract event.
-- Returns @Right@ containing a JSON representation of the event if a schema was present
-- and the event could be succesfully parsed using it.
-- and the event could be successfully parsed using it.
-- Returns @Left@ containing a hexadecimal representation of the raw event data otherwise.
showContractEvent :: Wasm.ContractEvent -> Either String String
showContractEvent ce@(Wasm.ContractEvent bs) = case toJSONString eventSchemaM bs of
Expand Down
Loading