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 1 commit
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
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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
2 changes: 1 addition & 1 deletion concordium-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/Concordium/concordium-client#readme>
homepage: https://github.com/Concordium/concordium-client#readme
bug-reports: https://github.com/Concordium/concordium-client/issues
Expand Down
64 changes: 32 additions & 32 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 @@ -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{..} ->
Expand Down Expand Up @@ -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. |]
rasmus-kirk marked this conversation as resolved.
Show resolved Hide resolved
)
<> [i|Got:\n|]
<> intercalate "\n" (map fromEither (map showContractEvent evs))
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions test/SimpleClientTests/TransactionSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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'.",
DOBEN marked this conversation as resolved.
Show resolved Hide resolved
"- 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"
]
Expand All @@ -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"
]
Expand Down
Loading