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

Commit

Permalink
Merge pull request #64 from JackalLabs/chain-id-api
Browse files Browse the repository at this point in the history
API: chain-id in the version response
  • Loading branch information
BiPhan4 authored Apr 24, 2023
2 parents 6c492fd + 4bcd01f commit c96f738
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 12 additions & 8 deletions jprov/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context)
ctx.Logger.Error(err.Error())
}

var v types.VersionResponse
clientCtx, error := client.GetClientTxContext(cmd)
if error != nil {
ctx.Logger.Error(err.Error())
return
}
chainID := clientCtx.ChainID

v := types.VersionResponse{
Version: version.Version,
ChainID: chainID,
}
if len(res) > 0 {
v = types.VersionResponse{
Version: res,
}
} else {
v = types.VersionResponse{
Version: version.Version,
}
v.Version = res
}

err = json.NewEncoder(w).Encode(v)
Expand Down
1 change: 1 addition & 0 deletions jprov/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ErrorResponse struct {

type VersionResponse struct {
Version string `json:"version"`
ChainID string `json:"chain-id"`
}

type Message interface{}
Expand Down

0 comments on commit c96f738

Please sign in to comment.