From 9b0d648b15f11b9288e2e2e9fd2b5a4a4902fdfa Mon Sep 17 00:00:00 2001 From: Doris Benda Date: Thu, 11 Apr 2024 21:44:21 +0300 Subject: [PATCH 1/4] Fix typos --- ChangeLog.md | 1 + README.md | 12 +++++ concordium-client.cabal | 2 +- src/Concordium/Client/Output.hs | 64 +++++++++++------------ test/SimpleClientTests/TransactionSpec.hs | 8 +-- 5 files changed, 50 insertions(+), 37 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2a2d3de5..cf89e7fc 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ ## Unreleased +- Fix a bug in correctly accounting for parsed events. - Update GHC version to 9.6.4 (lts-22.9). - Support protocol version 7. diff --git a/README.md b/README.md index 7f97066c..e7857d28 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/concordium-client.cabal b/concordium-client.cabal index 9f09660a..823be579 100644 --- a/concordium-client.cabal +++ b/concordium-client.cabal @@ -5,7 +5,7 @@ cabal-version: 1.24 -- see: https://github.com/sol/hpack name: concordium-client -version: 6.3.0 +version: 6.2.1 description: Please see the README on GitHub at homepage: https://github.com/Concordium/concordium-client#readme bug-reports: https://github.com/Concordium/concordium-client/issues diff --git a/src/Concordium/Client/Output.hs b/src/Concordium/Client/Output.hs index f6e918b1..5efe6075 100644 --- a/src/Concordium/Client/Output.hs +++ b/src/Concordium/Client/Output.hs @@ -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 @@ -782,68 +782,68 @@ showEvent :: Maybe String showEvent verbose ciM = \case Types.ModuleDeployed ref -> - verboseOrNothing $ printf "module '%s' deployed" (show ref) + verboseOrNothing $ printf "module '%s' deployed." (show ref) Types.ContractInitialized{..} -> verboseOrNothing $ [i|initialized contract '#{ecAddress}' using init function '#{ecInitName}' from module '#{ecRef}' |] - <> [i|with #{showCcd ecAmount}\n#{showLoggedEvents ecEvents}|] + <> [i|with #{showCcd ecAmount}.\n#{showLoggedEvents ecEvents}|] Types.Updated{..} -> verboseOrNothing $ [i|sent message to function '#{euReceiveName}' with #{showParameter euReceiveName euMessage} and #{showCcd euAmount} |] - <> [i|from #{showAddress euInstigator} to #{showAddress $ Types.AddressContract euAddress}\n|] + <> [i|from #{showAddress euInstigator} to #{showAddress $ Types.AddressContract euAddress}.\n|] <> [i|#{showLoggedEvents euEvents}|] Types.Transferred{..} -> - verboseOrNothing $ printf "transferred %s from %s to %s" (showCcd etAmount) (showAddress etFrom) (showAddress etTo) + verboseOrNothing $ printf "transferred %s from %s to %s." (showCcd etAmount) (showAddress etFrom) (showAddress etTo) Types.AccountCreated addr -> - verboseOrNothing $ printf "account '%s' created" (show addr) + verboseOrNothing $ printf "account '%s' created." (show addr) Types.CredentialDeployed{..} -> - verboseOrNothing $ printf "credential with registration '%s' deployed onto account '%s'" (show ecdRegId) (show ecdAccount) + verboseOrNothing $ printf "credential with registration '%s' deployed onto account '%s'." (show ecdRegId) (show ecdAccount) Types.BakerAdded{..} -> let restakeString :: String = if ebaRestakeEarnings then "Earnings are added to the stake." else "Earnings are not added to the stake." in verboseOrNothing $ printf "validator %s added, staking %s CCD. %s" (showBaker ebaBakerId ebaAccount) (Types.amountToString ebaStake) restakeString Types.BakerRemoved{..} -> - verboseOrNothing $ printf "validator %s, removed" (showBaker ebrBakerId ebrAccount) + verboseOrNothing $ printf "validator %s, removed." (showBaker ebrBakerId ebrAccount) Types.BakerStakeIncreased{..} -> - verboseOrNothing $ printf "validator %s stake increased to %s" (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) + verboseOrNothing $ printf "validator %s stake increased to %s." (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) Types.BakerStakeDecreased{..} -> - verboseOrNothing $ printf "validator %s stake decreased to %s" (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) + verboseOrNothing $ printf "validator %s stake decreased to %s." (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) Types.BakerSetRestakeEarnings{..} -> - verboseOrNothing $ printf "validator %s restake earnings %s" (showBaker ebsreBakerId ebsreAccount) (if ebsreRestakeEarnings then "set" :: String else "unset") + verboseOrNothing $ printf "validator %s restake earnings %s." (showBaker ebsreBakerId ebsreAccount) (if ebsreRestakeEarnings then "set" :: String else "unset") Types.BakerKeysUpdated{..} -> - verboseOrNothing $ printf "validator %s keys updated" (showBaker ebkuBakerId ebkuAccount) + verboseOrNothing $ printf "validator %s keys updated." (showBaker ebkuBakerId ebkuAccount) Types.CredentialsUpdated{..} -> verboseOrNothing $ [i|credentials on account #{cuAccount} have been updated.\nCredentials #{cuRemovedCredIds} have been removed, and credentials #{cuNewCredIds} have been added.\nThe new account threshold is #{cuNewThreshold}.|] Types.BakerSetOpenStatus{..} -> - verboseOrNothing $ printf "validator %s open status changed to %s" (showBaker ebsosBakerId ebsosAccount) (show ebsosOpenStatus) + verboseOrNothing $ printf "validator %s open status changed to %s." (showBaker ebsosBakerId ebsosAccount) (show ebsosOpenStatus) Types.BakerSetMetadataURL{..} -> - verboseOrNothing $ printf "validator %s URL changed to %s" (showBaker ebsmuBakerId ebsmuAccount) (show ebsmuMetadataURL) + verboseOrNothing $ printf "validator %s URL changed to %s." (showBaker ebsmuBakerId ebsmuAccount) (show ebsmuMetadataURL) Types.BakerSetTransactionFeeCommission{..} -> - verboseOrNothing $ printf "validator %s changed transaction fee commission to %s" (showBaker ebstfcBakerId ebstfcAccount) (show ebstfcTransactionFeeCommission) + verboseOrNothing $ printf "validator %s changed transaction fee commission to %s." (showBaker ebstfcBakerId ebstfcAccount) (show ebstfcTransactionFeeCommission) Types.BakerSetBakingRewardCommission{..} -> - verboseOrNothing $ printf "validator %s changed block reward commission to %s" (showBaker ebsbrcBakerId ebsbrcAccount) (show ebsbrcBakingRewardCommission) + verboseOrNothing $ printf "validator %s changed block reward commission to %s." (showBaker ebsbrcBakerId ebsbrcAccount) (show ebsbrcBakingRewardCommission) Types.BakerSetFinalizationRewardCommission{..} -> - verboseOrNothing $ printf "validator %s changed finalization reward commission to %s" (showBaker ebsfrcBakerId ebsfrcAccount) (show ebsfrcFinalizationRewardCommission) + verboseOrNothing $ printf "validator %s changed finalization reward commission to %s." (showBaker ebsfrcBakerId ebsfrcAccount) (show ebsfrcFinalizationRewardCommission) Types.DelegationStakeIncreased{..} -> - verboseOrNothing $ printf "delegator %s stake increased to %s" (showDelegator edsiDelegatorId edsiAccount) (showCcd edsiNewStake) + verboseOrNothing $ printf "delegator %s stake increased to %s." (showDelegator edsiDelegatorId edsiAccount) (showCcd edsiNewStake) Types.DelegationStakeDecreased{..} -> - verboseOrNothing $ printf "delegator %s stake decreased to %s" (showDelegator edsdDelegatorId edsdAccount) (showCcd edsdNewStake) + verboseOrNothing $ printf "delegator %s stake decreased to %s." (showDelegator edsdDelegatorId edsdAccount) (showCcd edsdNewStake) Types.DelegationSetRestakeEarnings{..} -> - verboseOrNothing $ printf "delegator %s restake earnings changed to %s" (showDelegator edsreDelegatorId edsreAccount) (show edsreRestakeEarnings) + verboseOrNothing $ printf "delegator %s restake earnings changed to %s." (showDelegator edsreDelegatorId edsreAccount) (show edsreRestakeEarnings) Types.DelegationSetDelegationTarget{..} -> - verboseOrNothing $ printf "delegator %s delegation target changed to %s" (showDelegator edsdtDelegatorId edsdtAccount) (showDelegationTarget edsdtDelegationTarget) + verboseOrNothing $ printf "delegator %s delegation target changed to %s." (showDelegator edsdtDelegatorId edsdtAccount) (showDelegationTarget edsdtDelegationTarget) Types.DelegationAdded{..} -> - verboseOrNothing $ printf "delegator %s added" (showDelegator edaDelegatorId edaAccount) + verboseOrNothing $ printf "delegator %s added." (showDelegator edaDelegatorId edaAccount) Types.DelegationRemoved{..} -> - verboseOrNothing $ printf "delegator %s removed" (showDelegator edrDelegatorId edrAccount) - Types.CredentialKeysUpdated cid -> verboseOrNothing $ printf "credential keys updated for credential with credId %s" (show cid) - Types.NewEncryptedAmount{..} -> verboseOrNothing $ printf "shielded amount received on account '%s' with index '%s'" (show neaAccount) (show neaNewIndex) - Types.EncryptedAmountsRemoved{..} -> verboseOrNothing $ printf "shielded amounts removed on account '%s' up to index '%s' with a resulting self shielded amount of '%s'" (show earAccount) (show earUpToIndex) (show earNewAmount) - Types.AmountAddedByDecryption{..} -> verboseOrNothing $ printf "transferred %s from the shielded balance to the public balance on account '%s'" (showCcd aabdAmount) (show aabdAccount) - Types.EncryptedSelfAmountAdded{..} -> verboseOrNothing $ printf "transferred %s from the public balance to the shielded balance on account '%s' with a resulting self shielded balance of '%s'" (showCcd eaaAmount) (show eaaAccount) (show eaaNewAmount) + verboseOrNothing $ printf "delegator %s removed." (showDelegator edrDelegatorId edrAccount) + Types.CredentialKeysUpdated cid -> verboseOrNothing $ printf "credential keys updated for credential with credId %s." (show cid) + Types.NewEncryptedAmount{..} -> verboseOrNothing $ printf "shielded amount received on account '%s' with index '%s'." (show neaAccount) (show neaNewIndex) + Types.EncryptedAmountsRemoved{..} -> verboseOrNothing $ printf "shielded amounts removed on account '%s' up to index '%s' with a resulting self shielded amount of '%s'." (show earAccount) (show earUpToIndex) (show earNewAmount) + Types.AmountAddedByDecryption{..} -> verboseOrNothing $ printf "transferred %s from the shielded balance to the public balance on account '%s'." (showCcd aabdAmount) (show aabdAccount) + Types.EncryptedSelfAmountAdded{..} -> verboseOrNothing $ printf "transferred %s from the public balance to the shielded balance on account '%s' with a resulting self shielded balance of '%s'." (showCcd eaaAmount) (show eaaAccount) (show eaaNewAmount) Types.UpdateEnqueued{..} -> verboseOrNothing $ printf "Enqueued chain update, effective at %s:\n%s" (showTimeFormatted (timeFromTransactionExpiryTime ueEffectiveTime)) (show uePayload) Types.TransferredWithSchedule{..} -> - verboseOrNothing $ printf "Sent transfer with schedule %s" (intercalate ", " . map (\(a, b) -> showTimeFormatted (Time.timestampToUTCTime a) ++ ": " ++ showCcd b) $ etwsAmount) + verboseOrNothing $ printf "Sent transfer with schedule %s." (intercalate ", " . map (\(a, b) -> showTimeFormatted (Time.timestampToUTCTime a) ++ ": " ++ showCcd b) $ etwsAmount) Types.DataRegistered{} -> verboseOrNothing [i|Registered data on chain.|] Types.TransferMemo{..} -> @@ -904,10 +904,10 @@ 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 #{length $ filter isRight $ map showContractEvent evs} #{if (length $ filter isRight $ map showContractEvent evs) > 1 then "were" else ("was" :: String)} successfully parsed. |] ) <> [i|Got:\n|] <> intercalate "\n" (map fromEither (map showContractEvent evs)) @@ -920,7 +920,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 diff --git a/test/SimpleClientTests/TransactionSpec.hs b/test/SimpleClientTests/TransactionSpec.hs index 462b6349..02e0be3f 100644 --- a/test/SimpleClientTests/TransactionSpec.hs +++ b/test/SimpleClientTests/TransactionSpec.hs @@ -250,16 +250,16 @@ printTransactionStatusTests = describe "print transaction status" $ do p committedTwoDifferentSuccessfulOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'", + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", "- 941c24374cd077de2120fb58732306c3115a08bb7b7cda120a04fecc412b1795 with status \"success\" and cost 0.000020 CCD (20 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'" + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'." ] describe "committed into two blocks" $ specify "correct output" $ p committedSuccessfulAndFailureOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'", + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", "- be880f81dfbcc0a049c3defe483327d0a2a3002a186a06d34bcd93a9be7f9994 with status \"rejected\" and cost 0.000020 CCD (20 NRG):", " * account or contract '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' does not have enough funds to transfer 0.000011 CCD" ] @@ -268,7 +268,7 @@ printTransactionStatusTests = describe "print transaction status" $ do p committedSuccessfulAndFailureOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'", + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", "- be880f81dfbcc0a049c3defe483327d0a2a3002a186a06d34bcd93a9be7f9994 with status \"rejected\" and cost 0.000020 CCD (20 NRG):", " * account or contract '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' does not have enough funds to transfer 0.000011 CCD" ] From db29f9a745d6d80085f57fc16b7fbfc9379999d9 Mon Sep 17 00:00:00 2001 From: rasmus-kirk Date: Thu, 12 Sep 2024 14:29:21 +0200 Subject: [PATCH 2/4] Used prettyMsg. Also refactored as per Thomas' request. --- src/Concordium/Client/Output.hs | 92 ++++++++++++----------- test/SimpleClientTests/TransactionSpec.hs | 8 +- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/src/Concordium/Client/Output.hs b/src/Concordium/Client/Output.hs index 8a8842e7..832f0557 100644 --- a/src/Concordium/Client/Output.hs +++ b/src/Concordium/Client/Output.hs @@ -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), "" @@ -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. @@ -766,7 +765,8 @@ showOutcomeResult verbose contrInfoWithEventsM = \case Types.Resumed{} -> (idt - 4, idt - 4) _ -> (idt, idt) - evStringM = fmap (indentBy idtCurrent) (showEvent verbose cInfo ev) + evStringM = fmap (indentBy idtCurrent . prettyMsg ".") (showEvent verbose cInfo ev) + in (idtFollowing, out <> [evStringM]) @@ -790,7 +790,7 @@ showEvent :: Maybe String showEvent verbose ciM = \case Types.ModuleDeployed ref -> - verboseOrNothing $ printf "module '%s' deployed." (show ref) + verboseOrNothing $ printf "module '%s' deployed" (show ref) Types.ContractInitialized{..} -> verboseOrNothing $ [i|initialized contract '#{ecAddress}' using init function '#{ecInitName}' from module '#{ecRef}' |] @@ -801,62 +801,62 @@ showEvent verbose ciM = \case <> [i|from #{showAddress euInstigator} to #{showAddress $ Types.AddressContract euAddress}.\n|] <> [i|#{showLoggedEvents euEvents}|] Types.Transferred{..} -> - verboseOrNothing $ printf "transferred %s from %s to %s." (showCcd etAmount) (showAddress etFrom) (showAddress etTo) + verboseOrNothing $ printf "transferred %s from %s to %s" (showCcd etAmount) (showAddress etFrom) (showAddress etTo) Types.AccountCreated addr -> - verboseOrNothing $ printf "account '%s' created." (show addr) + verboseOrNothing $ printf "account '%s' created" (show addr) Types.CredentialDeployed{..} -> - verboseOrNothing $ printf "credential with registration '%s' deployed onto account '%s'." (show ecdRegId) (show ecdAccount) + verboseOrNothing $ printf "credential with registration '%s' deployed onto account '%s'" (show ecdRegId) (show ecdAccount) Types.BakerAdded{..} -> - let restakeString :: String = if ebaRestakeEarnings then "Earnings are added to the stake." else "Earnings are not added to the stake." + let restakeString :: String = if ebaRestakeEarnings then "Earnings are added to the stake" else "Earnings are not added to the stake" in verboseOrNothing $ printf "validator %s added, staking %s CCD. %s" (showBaker ebaBakerId ebaAccount) (Types.amountToString ebaStake) restakeString Types.BakerRemoved{..} -> - verboseOrNothing $ printf "validator %s, removed." (showBaker ebrBakerId ebrAccount) + verboseOrNothing $ printf "validator %s, removed" (showBaker ebrBakerId ebrAccount) Types.BakerStakeIncreased{..} -> - verboseOrNothing $ printf "validator %s stake increased to %s." (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) + verboseOrNothing $ printf "validator %s stake increased to %s" (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) Types.BakerStakeDecreased{..} -> - verboseOrNothing $ printf "validator %s stake decreased to %s." (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) + verboseOrNothing $ printf "validator %s stake decreased to %s" (showBaker ebsiBakerId ebsiAccount) (showCcd ebsiNewStake) Types.BakerSetRestakeEarnings{..} -> - verboseOrNothing $ printf "validator %s restake earnings %s." (showBaker ebsreBakerId ebsreAccount) (if ebsreRestakeEarnings then "set" :: String else "unset") + verboseOrNothing $ printf "validator %s restake earnings %s" (showBaker ebsreBakerId ebsreAccount) (if ebsreRestakeEarnings then "set" :: String else "unset") Types.BakerKeysUpdated{..} -> - verboseOrNothing $ printf "validator %s keys updated." (showBaker ebkuBakerId ebkuAccount) + verboseOrNothing $ printf "validator %s keys updated" (showBaker ebkuBakerId ebkuAccount) Types.CredentialsUpdated{..} -> verboseOrNothing $ [i|credentials on account #{cuAccount} have been updated.\nCredentials #{cuRemovedCredIds} have been removed, and credentials #{cuNewCredIds} have been added.\nThe new account threshold is #{cuNewThreshold}.|] Types.BakerSetOpenStatus{..} -> - verboseOrNothing $ printf "validator %s open status changed to %s." (showBaker ebsosBakerId ebsosAccount) (show ebsosOpenStatus) + verboseOrNothing $ printf "validator %s open status changed to %s" (showBaker ebsosBakerId ebsosAccount) (show ebsosOpenStatus) Types.BakerSetMetadataURL{..} -> - verboseOrNothing $ printf "validator %s URL changed to %s." (showBaker ebsmuBakerId ebsmuAccount) (show ebsmuMetadataURL) + verboseOrNothing $ printf "validator %s URL changed to %s" (showBaker ebsmuBakerId ebsmuAccount) (show ebsmuMetadataURL) Types.BakerSetTransactionFeeCommission{..} -> - verboseOrNothing $ printf "validator %s changed transaction fee commission to %s." (showBaker ebstfcBakerId ebstfcAccount) (show ebstfcTransactionFeeCommission) + verboseOrNothing $ printf "validator %s changed transaction fee commission to %s" (showBaker ebstfcBakerId ebstfcAccount) (show ebstfcTransactionFeeCommission) Types.BakerSetBakingRewardCommission{..} -> - verboseOrNothing $ printf "validator %s changed block reward commission to %s." (showBaker ebsbrcBakerId ebsbrcAccount) (show ebsbrcBakingRewardCommission) + verboseOrNothing $ printf "validator %s changed block reward commission to %s" (showBaker ebsbrcBakerId ebsbrcAccount) (show ebsbrcBakingRewardCommission) Types.BakerSetFinalizationRewardCommission{..} -> - verboseOrNothing $ printf "validator %s changed finalization reward commission to %s." (showBaker ebsfrcBakerId ebsfrcAccount) (show ebsfrcFinalizationRewardCommission) + verboseOrNothing $ printf "validator %s changed finalization reward commission to %s" (showBaker ebsfrcBakerId ebsfrcAccount) (show ebsfrcFinalizationRewardCommission) Types.DelegationStakeIncreased{..} -> - verboseOrNothing $ printf "delegator %s stake increased to %s." (showDelegator edsiDelegatorId edsiAccount) (showCcd edsiNewStake) + verboseOrNothing $ printf "delegator %s stake increased to %s" (showDelegator edsiDelegatorId edsiAccount) (showCcd edsiNewStake) Types.DelegationStakeDecreased{..} -> - verboseOrNothing $ printf "delegator %s stake decreased to %s." (showDelegator edsdDelegatorId edsdAccount) (showCcd edsdNewStake) + verboseOrNothing $ printf "delegator %s stake decreased to %s" (showDelegator edsdDelegatorId edsdAccount) (showCcd edsdNewStake) Types.DelegationSetRestakeEarnings{..} -> - verboseOrNothing $ printf "delegator %s restake earnings changed to %s." (showDelegator edsreDelegatorId edsreAccount) (show edsreRestakeEarnings) + verboseOrNothing $ printf "delegator %s restake earnings changed to %s" (showDelegator edsreDelegatorId edsreAccount) (show edsreRestakeEarnings) Types.DelegationSetDelegationTarget{..} -> - verboseOrNothing $ printf "delegator %s delegation target changed to %s." (showDelegator edsdtDelegatorId edsdtAccount) (showDelegationTarget edsdtDelegationTarget) + verboseOrNothing $ printf "delegator %s delegation target changed to %s" (showDelegator edsdtDelegatorId edsdtAccount) (showDelegationTarget edsdtDelegationTarget) Types.DelegationAdded{..} -> - verboseOrNothing $ printf "delegator %s added." (showDelegator edaDelegatorId edaAccount) + verboseOrNothing $ printf "delegator %s added" (showDelegator edaDelegatorId edaAccount) Types.DelegationRemoved{..} -> - verboseOrNothing $ printf "delegator %s removed." (showDelegator edrDelegatorId edrAccount) - Types.CredentialKeysUpdated cid -> verboseOrNothing $ printf "credential keys updated for credential with credId %s." (show cid) - Types.NewEncryptedAmount{..} -> verboseOrNothing $ printf "shielded amount received on account '%s' with index '%s'." (show neaAccount) (show neaNewIndex) - Types.EncryptedAmountsRemoved{..} -> verboseOrNothing $ printf "shielded amounts removed on account '%s' up to index '%s' with a resulting self shielded amount of '%s'." (show earAccount) (show earUpToIndex) (show earNewAmount) - Types.AmountAddedByDecryption{..} -> verboseOrNothing $ printf "transferred %s from the shielded balance to the public balance on account '%s'." (showCcd aabdAmount) (show aabdAccount) - Types.EncryptedSelfAmountAdded{..} -> verboseOrNothing $ printf "transferred %s from the public balance to the shielded balance on account '%s' with a resulting self shielded balance of '%s'." (showCcd eaaAmount) (show eaaAccount) (show eaaNewAmount) + verboseOrNothing $ printf "delegator %s removed" (showDelegator edrDelegatorId edrAccount) + Types.CredentialKeysUpdated cid -> verboseOrNothing $ printf "credential keys updated for credential with credId %s" (show cid) + Types.NewEncryptedAmount{..} -> verboseOrNothing $ printf "shielded amount received on account '%s' with index '%s'" (show neaAccount) (show neaNewIndex) + Types.EncryptedAmountsRemoved{..} -> verboseOrNothing $ printf "shielded amounts removed on account '%s' up to index '%s' with a resulting self shielded amount of '%s'" (show earAccount) (show earUpToIndex) (show earNewAmount) + Types.AmountAddedByDecryption{..} -> verboseOrNothing $ printf "transferred %s from the shielded balance to the public balance on account '%s'" (showCcd aabdAmount) (show aabdAccount) + Types.EncryptedSelfAmountAdded{..} -> verboseOrNothing $ printf "transferred %s from the public balance to the shielded balance on account '%s' with a resulting self shielded balance of '%s'" (showCcd eaaAmount) (show eaaAccount) (show eaaNewAmount) Types.UpdateEnqueued{..} -> verboseOrNothing $ printf "Enqueued chain update, effective at %s:\n%s" (showTimeFormatted (timeFromTransactionExpiryTime ueEffectiveTime)) (show uePayload) Types.TransferredWithSchedule{..} -> - verboseOrNothing $ printf "Sent transfer with schedule %s." (intercalate ", " . map (\(a, b) -> showTimeFormatted (Time.timestampToUTCTime a) ++ ": " ++ showCcd b) $ etwsAmount) + verboseOrNothing $ printf "Sent transfer with schedule %s" (intercalate ", " . map (\(a, b) -> showTimeFormatted (Time.timestampToUTCTime a) ++ ": " ++ showCcd b) $ etwsAmount) Types.DataRegistered{} -> verboseOrNothing [i|Registered data on chain.|] Types.TransferMemo{..} -> let (Types.Memo bss) = tmMemo - invalidCBOR = printf "Could not decode memo as valid CBOR. The hex value of the memo is %s." $ show tmMemo + invalidCBOR = printf "Could not decode memo as valid CBOR. The hex value of the memo is %s" $ show tmMemo bsl = BSL.fromStrict $ BSS.fromShort bss str = case deserialiseFromBytes decodeString bsl of -- Try to decode the memo as a CBOR string Left _ -> json -- if not possible, try to decode as JSON @@ -874,10 +874,10 @@ showEvent verbose ciM = \case Types.Interrupted cAddr ev -> verboseOrNothing [i|interrupted '#{cAddr}'.\n#{showLoggedEvents ev}|] Types.Upgraded{..} -> - verboseOrNothing [i|upgraded contract instance at '#{euAddress}' from '#{euFrom}' to '#{euTo}'.|] + verboseOrNothing [i|upgraded contract instance at '#{euAddress}' from '#{euFrom}' to '#{euTo}'|] Types.Resumed cAddr invokeSucceeded -> let invokeMsg :: Text = if invokeSucceeded then "succeeded" else "failed" - in verboseOrNothing [i|resumed '#{cAddr}' after an interruption that #{invokeMsg}.|] + in verboseOrNothing [i|resumed '#{cAddr}' after an interruption that #{invokeMsg}|] where verboseOrNothing :: String -> Maybe String verboseOrNothing msg = if verbose then Just msg else Nothing @@ -910,16 +910,18 @@ showEvent verbose ciM = \case -- Show events logged in a contract. showLoggedEvents :: [Wasm.ContractEvent] -> String - showLoggedEvents [] = "No contract events were emitted." + showLoggedEvents [] = "No contract events were emitted" showLoggedEvents evs = [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 isRight $ map showContractEvent evs} #{if (length $ filter isRight $ map showContractEvent evs) > 1 then "were" else ("was" :: String)} successfully parsed. |] + else [i|, of which #{noOfParsedEvents} #{if noOfParsedEvents > 1 then "were" else ("was" :: String)} successfully parsed. |] ) <> [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 diff --git a/test/SimpleClientTests/TransactionSpec.hs b/test/SimpleClientTests/TransactionSpec.hs index b913c38f..3017df6a 100644 --- a/test/SimpleClientTests/TransactionSpec.hs +++ b/test/SimpleClientTests/TransactionSpec.hs @@ -285,16 +285,16 @@ printTransactionStatusTests = describe "print transaction status" $ do p committedTwoDifferentSuccessfulOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", + " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", "- 941c24374cd077de2120fb58732306c3115a08bb7b7cda120a04fecc412b1795 with status \"success\" and cost 0.000020 CCD (20 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'." + " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'." ] describe "committed into two blocks" $ specify "correct output" $ p committedSuccessfulAndFailureOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", + " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", "- be880f81dfbcc0a049c3defe483327d0a2a3002a186a06d34bcd93a9be7f9994 with status \"rejected\" and cost 0.000020 CCD (20 NRG):", " * account or contract '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' does not have enough funds to transfer 0.000011 CCD" ] @@ -303,7 +303,7 @@ printTransactionStatusTests = describe "print transaction status" $ do p committedSuccessfulAndFailureOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", + " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", "- be880f81dfbcc0a049c3defe483327d0a2a3002a186a06d34bcd93a9be7f9994 with status \"rejected\" and cost 0.000020 CCD (20 NRG):", " * account or contract '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' does not have enough funds to transfer 0.000011 CCD" ] From d5ef5e79b0f80ee8051960744938c6d943a380d0 Mon Sep 17 00:00:00 2001 From: rasmus-kirk Date: Thu, 12 Sep 2024 16:33:36 +0200 Subject: [PATCH 3/4] Removed punctuation changes from this branch --- ChangeLog.md | 3 +++ src/Concordium/Client/Output.hs | 17 ++++++++--------- test/SimpleClientTests/TransactionSpec.hs | 8 ++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f0acb65a..b4d885ae 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -27,6 +27,9 @@ `transaction add-signature`.) - Add optional `--out` flag to all transaction-creating commands to output a partially-singed transaction to a file. +- Update GHC version to 9.6.4 (lts-22.9). +- Update Rust version to 1.73. +- Preliminary support for protocol version 7. ## 6.2.1 diff --git a/src/Concordium/Client/Output.hs b/src/Concordium/Client/Output.hs index 832f0557..4e5c5885 100644 --- a/src/Concordium/Client/Output.hs +++ b/src/Concordium/Client/Output.hs @@ -765,8 +765,7 @@ showOutcomeResult verbose contrInfoWithEventsM = \case Types.Resumed{} -> (idt - 4, idt - 4) _ -> (idt, idt) - evStringM = fmap (indentBy idtCurrent . prettyMsg ".") (showEvent verbose cInfo ev) - + evStringM = fmap (indentBy idtCurrent) (showEvent verbose cInfo ev) in (idtFollowing, out <> [evStringM]) @@ -794,11 +793,11 @@ showEvent verbose ciM = \case Types.ContractInitialized{..} -> verboseOrNothing $ [i|initialized contract '#{ecAddress}' using init function '#{ecInitName}' from module '#{ecRef}' |] - <> [i|with #{showCcd ecAmount}.\n#{showLoggedEvents ecEvents}|] + <> [i|with #{showCcd ecAmount}\n#{showLoggedEvents ecEvents}|] Types.Updated{..} -> verboseOrNothing $ [i|sent message to function '#{euReceiveName}' with #{showParameter euReceiveName euMessage} and #{showCcd euAmount} |] - <> [i|from #{showAddress euInstigator} to #{showAddress $ Types.AddressContract euAddress}.\n|] + <> [i|from #{showAddress euInstigator} to #{showAddress $ Types.AddressContract euAddress}\n|] <> [i|#{showLoggedEvents euEvents}|] Types.Transferred{..} -> verboseOrNothing $ printf "transferred %s from %s to %s" (showCcd etAmount) (showAddress etFrom) (showAddress etTo) @@ -807,7 +806,7 @@ showEvent verbose ciM = \case Types.CredentialDeployed{..} -> verboseOrNothing $ printf "credential with registration '%s' deployed onto account '%s'" (show ecdRegId) (show ecdAccount) Types.BakerAdded{..} -> - let restakeString :: String = if ebaRestakeEarnings then "Earnings are added to the stake" else "Earnings are not added to the stake" + let restakeString :: String = if ebaRestakeEarnings then "Earnings are added to the stake." else "Earnings are not added to the stake." in verboseOrNothing $ printf "validator %s added, staking %s CCD. %s" (showBaker ebaBakerId ebaAccount) (Types.amountToString ebaStake) restakeString Types.BakerRemoved{..} -> verboseOrNothing $ printf "validator %s, removed" (showBaker ebrBakerId ebrAccount) @@ -856,7 +855,7 @@ showEvent verbose ciM = \case verboseOrNothing [i|Registered data on chain.|] Types.TransferMemo{..} -> let (Types.Memo bss) = tmMemo - invalidCBOR = printf "Could not decode memo as valid CBOR. The hex value of the memo is %s" $ show tmMemo + invalidCBOR = printf "Could not decode memo as valid CBOR. The hex value of the memo is %s." $ show tmMemo bsl = BSL.fromStrict $ BSS.fromShort bss str = case deserialiseFromBytes decodeString bsl of -- Try to decode the memo as a CBOR string Left _ -> json -- if not possible, try to decode as JSON @@ -874,10 +873,10 @@ showEvent verbose ciM = \case Types.Interrupted cAddr ev -> verboseOrNothing [i|interrupted '#{cAddr}'.\n#{showLoggedEvents ev}|] Types.Upgraded{..} -> - verboseOrNothing [i|upgraded contract instance at '#{euAddress}' from '#{euFrom}' to '#{euTo}'|] + verboseOrNothing [i|upgraded contract instance at '#{euAddress}' from '#{euFrom}' to '#{euTo}'.|] Types.Resumed cAddr invokeSucceeded -> let invokeMsg :: Text = if invokeSucceeded then "succeeded" else "failed" - in verboseOrNothing [i|resumed '#{cAddr}' after an interruption that #{invokeMsg}|] + in verboseOrNothing [i|resumed '#{cAddr}' after an interruption that #{invokeMsg}.|] where verboseOrNothing :: String -> Maybe String verboseOrNothing msg = if verbose then Just msg else Nothing @@ -910,7 +909,7 @@ showEvent verbose ciM = \case -- Show events logged in a contract. showLoggedEvents :: [Wasm.ContractEvent] -> String - showLoggedEvents [] = "No contract events were emitted" + showLoggedEvents [] = "No contract events were emitted." showLoggedEvents evs = [i|#{length evs} contract #{if length evs > 1 then "events were" else ("event was" :: String)} emitted|] <> ( if isNothing eventSchemaM diff --git a/test/SimpleClientTests/TransactionSpec.hs b/test/SimpleClientTests/TransactionSpec.hs index 3017df6a..f4cd105b 100644 --- a/test/SimpleClientTests/TransactionSpec.hs +++ b/test/SimpleClientTests/TransactionSpec.hs @@ -285,16 +285,16 @@ printTransactionStatusTests = describe "print transaction status" $ do p committedTwoDifferentSuccessfulOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'", "- 941c24374cd077de2120fb58732306c3115a08bb7b7cda120a04fecc412b1795 with status \"success\" and cost 0.000020 CCD (20 NRG):", - " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'." + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'" ] describe "committed into two blocks" $ specify "correct output" $ p committedSuccessfulAndFailureOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'", "- be880f81dfbcc0a049c3defe483327d0a2a3002a186a06d34bcd93a9be7f9994 with status \"rejected\" and cost 0.000020 CCD (20 NRG):", " * account or contract '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' does not have enough funds to transfer 0.000011 CCD" ] @@ -303,7 +303,7 @@ printTransactionStatusTests = describe "print transaction status" $ do p committedSuccessfulAndFailureOutcomes `shouldBe` [ "Transaction is committed into 2 blocks:", "- 0a5d64f644461d95315a781475b83f723f74d1c21542bd4f3e234d6173374389 with status \"success\" and cost 0.000010 CCD (10 NRG):", - " * Transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'.", + " * transferred 0.000010 CCD from account '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' to account '4MkK65HrYvMauNTHTuL23wRDKp4VXkCiTpmoWYFtsrZHV3WwSa'", "- be880f81dfbcc0a049c3defe483327d0a2a3002a186a06d34bcd93a9be7f9994 with status \"rejected\" and cost 0.000020 CCD (20 NRG):", " * account or contract '2zR4h351M1bqhrL9UywsbHrP3ucA1xY3TBTFRuTsRout8JnLD6' does not have enough funds to transfer 0.000011 CCD" ] From b862d4982484c8af264359c82b360c5a813264e0 Mon Sep 17 00:00:00 2001 From: rasmus-kirk Date: Thu, 19 Sep 2024 15:11:48 +0200 Subject: [PATCH 4/4] Addressed comment --- src/Concordium/Client/Output.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Concordium/Client/Output.hs b/src/Concordium/Client/Output.hs index 4e5c5885..34ad47a6 100644 --- a/src/Concordium/Client/Output.hs +++ b/src/Concordium/Client/Output.hs @@ -911,7 +911,7 @@ showEvent verbose ciM = \case showLoggedEvents :: [Wasm.ContractEvent] -> String showLoggedEvents [] = "No contract events were emitted." showLoggedEvents evs = - [i|#{length evs} contract #{if length evs > 1 then "events were" else ("event was" :: String)} 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 #{noOfParsedEvents} #{if noOfParsedEvents > 1 then "were" else ("was" :: String)} successfully parsed. |]