Skip to content

Commit

Permalink
Merge branch 'main' into available-balance
Browse files Browse the repository at this point in the history
  • Loading branch information
td202 authored Sep 19, 2024
2 parents f5606a3 + 09c7f5f commit dbd2918
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ tmp/
gtu-drop-account.json
hie.yaml
out/
# Nix stuff
flake.nix
flake.lock
shell.nix
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## Unreleased

- Display the correct "at disposal" balance when used with node versions prior to 7.
- Fix a bug in correctly accounting for parsed events.
- Change `--out` flag for `./client validator add` to
`--validator-credentials-out`, fixing an issue where this command had two
conflicting`--out` options.

## 7.0.0

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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
docker build -t concordium/linux-distributable-concordium-client \
-f scripts/distributables/linux-distributable-concordium-client.Dockerfile \
--build-arg GHC_VERSION=$GHC_VERSION \
--ssh default .
.

mkdir out

Expand Down
9 changes: 0 additions & 9 deletions scripts/distributables/linux-concordium-client.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ pipeline {
OUTFILE = "s3://distribution.concordium.software/tools/linux/concordium-client_${VERSION}"
}
stages {
stage('ecr-login') {
steps {
sh 'aws ecr get-login-password \
--region eu-west-1 \
| docker login \
--username AWS \
--password-stdin 192549843005.dkr.ecr.eu-west-1.amazonaws.com'
}
}
stage('precheck') {
steps {
sh '''\
Expand Down
2 changes: 1 addition & 1 deletion src/Concordium/Client/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ bakerAddCmd =
<*> blockCommission
<*> (option (eitherReader amountFractionFromStringInform) (long "delegation-finalization-commission" <> metavar "DECIMAL-FRACTION" <> help ("Fraction the validator takes in commission from delegators on finalization rewards. " ++ rangesHelpString "finalization reward commission")))
)
<*> optional (strOption (long "out" <> metavar "FILE" <> help "File to write the validator credentials to, in case of successful transaction. These can be used to start the node."))
<*> optional (strOption (long "validator-credentials-out" <> metavar "FILE" <> help "File to write the validator credentials to, in case of successful transaction. These can be used to start the node."))
)
(progDesc "Deploy validator credentials to the chain.")
)
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. |]
)
<> [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

0 comments on commit dbd2918

Please sign in to comment.