Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

EVM-720 Implement json output for all commands #1724

Merged
merged 11 commits into from
Jul 24, 2023
18 changes: 12 additions & 6 deletions command/rootchain/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ func runCommand(cmd *cobra.Command, _ []string) {
chainConfig.Params.ChainID, consensusCfg.InitialValidatorSet, cmd.Context())
if err != nil {
outputter.SetError(fmt.Errorf("failed to deploy rootchain contracts: %w", err))
outputter.SetCommandResult(command.Results(deploymentResultInfo.CommandResults))

return
}
Expand Down Expand Up @@ -384,7 +385,7 @@ func runCommand(cmd *cobra.Command, _ []string) {
return
}

outputter.WriteCommandResult(&helper.MessageResult{
deploymentResultInfo.CommandResults = append(deploymentResultInfo.CommandResults, &helper.MessageResult{
Message: fmt.Sprintf("%s finished. All contracts are successfully deployed and initialized.",
contractsDeploymentTitle),
})
Expand Down Expand Up @@ -544,18 +545,23 @@ func deployContracts(outputter command.OutputFormatter, client *jsonrpc.Client,
}

if err := g.Wait(); err != nil {
outputter.WriteCommandResult(&helper.MessageResult{
Message: "[ROOTCHAIN - DEPLOY] Successfully deployed the following contracts\n"})
results := []command.CommandResult{}
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved

messageResult := helper.MessageResult{
Message: "[ROOTCHAIN - DEPLOY] Successfully deployed the following contracts\n"}
results = append(results, messageResult)

for _, result := range results {
for i, result := range results {
if result != nil {
// In case an error happened, some of the indices may not be populated.
// Filter those out.
outputter.WriteCommandResult(result)
commandResults[i] = result
}
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
}

return deploymentResultInfo{nil, 0, nil}, err
results = append(results, commandResults...)

return deploymentResultInfo{nil, 0, results}, err
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
}

for i, result := range results {
Expand Down