From d1285db4b579c8e68ee1710dd0bae1878e74acc7 Mon Sep 17 00:00:00 2001 From: Marston Connell <34043723+TheMarstonConnell@users.noreply.github.com> Date: Mon, 24 Apr 2023 11:54:50 -0400 Subject: [PATCH 1/9] chainid in the version response --- jprov/server/http.go | 3 +++ jprov/types/types.go | 1 + 2 files changed, 4 insertions(+) diff --git a/jprov/server/http.go b/jprov/server/http.go index 0a1f0b3..20c9f68 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -53,10 +53,13 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) ctx.Logger.Error(err.Error()) } + clientContext := client.GetClientContextFromCmd(cmd) + var v types.VersionResponse if len(res) > 0 { v = types.VersionResponse{ Version: res, + ChainID: clientContext.ChainID, } } else { v = types.VersionResponse{ diff --git a/jprov/types/types.go b/jprov/types/types.go index 1dd1620..343ed30 100644 --- a/jprov/types/types.go +++ b/jprov/types/types.go @@ -31,6 +31,7 @@ type ErrorResponse struct { type VersionResponse struct { Version string `json:"version"` + ChainID string `json:"chain-id"` } type Message interface{} From cc93c82677813a272f1b30b2c7f1eeadcc3e07d1 Mon Sep 17 00:00:00 2001 From: BiPhan4 Date: Mon, 24 Apr 2023 18:15:03 -0400 Subject: [PATCH 2/9] declare chainID first --- jprov/server/http.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jprov/server/http.go b/jprov/server/http.go index 20c9f68..7031458 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -54,12 +54,13 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) } clientContext := client.GetClientContextFromCmd(cmd) + chainID := clientContext.ChainID var v types.VersionResponse if len(res) > 0 { v = types.VersionResponse{ Version: res, - ChainID: clientContext.ChainID, + ChainID: chainID, } } else { v = types.VersionResponse{ From 15c3327e99556f8a73aa654e39fccf5a3dd7a8a9 Mon Sep 17 00:00:00 2001 From: BiPhan4 Date: Mon, 24 Apr 2023 18:21:51 -0400 Subject: [PATCH 3/9] save --- jprov/server/http.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jprov/server/http.go b/jprov/server/http.go index 7031458..ea3db3a 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -53,14 +53,13 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) ctx.Logger.Error(err.Error()) } - clientContext := client.GetClientContextFromCmd(cmd) - chainID := clientContext.ChainID + clientCtx, err := client.GetClientTxContext(cmd) var v types.VersionResponse if len(res) > 0 { v = types.VersionResponse{ Version: res, - ChainID: chainID, + ChainID: clientCtx.ChainID, } } else { v = types.VersionResponse{ From 313cc4be2189dbfbb8b63b9f4cdfc0b6e4d529e5 Mon Sep 17 00:00:00 2001 From: BiPhan4 Date: Mon, 24 Apr 2023 18:30:11 -0400 Subject: [PATCH 4/9] use GetClientTxContext() and declare chainID first --- jprov/server/http.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jprov/server/http.go b/jprov/server/http.go index ea3db3a..0cf885a 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -54,12 +54,13 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) } clientCtx, err := client.GetClientTxContext(cmd) + chainID := clientCtx.ChainID var v types.VersionResponse if len(res) > 0 { v = types.VersionResponse{ Version: res, - ChainID: clientCtx.ChainID, + ChainID: chainID, } } else { v = types.VersionResponse{ From ea568bf7958320a566df85eed021ce53ca5ccc13 Mon Sep 17 00:00:00 2001 From: BiPhan4 Date: Mon, 24 Apr 2023 18:33:04 -0400 Subject: [PATCH 5/9] lint --- jprov/server/http.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jprov/server/http.go b/jprov/server/http.go index 0cf885a..78fead9 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -53,7 +53,11 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) ctx.Logger.Error(err.Error()) } - clientCtx, err := client.GetClientTxContext(cmd) + clientCtx, error := client.GetClientTxContext(cmd) + if error != nil { + ctx.Logger.Error(err.Error()) + return + } chainID := clientCtx.ChainID var v types.VersionResponse From c4005c868e883ecca01f8469e3b05e9b70f15cf2 Mon Sep 17 00:00:00 2001 From: BiPhan4 Date: Mon, 24 Apr 2023 18:43:08 -0400 Subject: [PATCH 6/9] experiment: is the VersionResponse struct actually saving? --- jprov/server/http.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jprov/server/http.go b/jprov/server/http.go index 78fead9..becbc83 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -53,18 +53,18 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) ctx.Logger.Error(err.Error()) } - clientCtx, error := client.GetClientTxContext(cmd) - if error != nil { - ctx.Logger.Error(err.Error()) - return - } - chainID := clientCtx.ChainID + // clientCtx, error := client.GetClientTxContext(cmd) + // if error != nil { + // ctx.Logger.Error(err.Error()) + // return + // } + // chainID := clientCtx.ChainID var v types.VersionResponse if len(res) > 0 { v = types.VersionResponse{ Version: res, - ChainID: chainID, + ChainID: "test-chain", } } else { v = types.VersionResponse{ From bbf8bc7e59af0f0dc9ba4cbf584d2343038d8a21 Mon Sep 17 00:00:00 2001 From: BiPhan4 Date: Mon, 24 Apr 2023 18:49:50 -0400 Subject: [PATCH 7/9] ChainID shows up even if I don't put in version flag? --- jprov/server/http.go | 1 + 1 file changed, 1 insertion(+) diff --git a/jprov/server/http.go b/jprov/server/http.go index becbc83..c8357ab 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -69,6 +69,7 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) } else { v = types.VersionResponse{ Version: version.Version, + ChainID: "test-chain", } } From 6ecc93563f2770ee31b1ec47e33142e24cbd2b3d Mon Sep 17 00:00:00 2001 From: BiPhan4 Date: Mon, 24 Apr 2023 18:55:08 -0400 Subject: [PATCH 8/9] bring back the real chainID to see if this works --- jprov/server/http.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jprov/server/http.go b/jprov/server/http.go index c8357ab..36e3cde 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -53,23 +53,23 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) ctx.Logger.Error(err.Error()) } - // clientCtx, error := client.GetClientTxContext(cmd) - // if error != nil { - // ctx.Logger.Error(err.Error()) - // return - // } - // chainID := clientCtx.ChainID + clientCtx, error := client.GetClientTxContext(cmd) + if error != nil { + ctx.Logger.Error(err.Error()) + return + } + chainID := clientCtx.ChainID var v types.VersionResponse if len(res) > 0 { v = types.VersionResponse{ Version: res, - ChainID: "test-chain", + ChainID: chainID, } } else { v = types.VersionResponse{ Version: version.Version, - ChainID: "test-chain", + ChainID: chainID, } } From 4bcd01f28e0577db4e0d68809df75e4023039f66 Mon Sep 17 00:00:00 2001 From: Marston Connell <34043723+TheMarstonConnell@users.noreply.github.com> Date: Mon, 24 Apr 2023 18:58:22 -0400 Subject: [PATCH 9/9] cleaning --- jprov/server/http.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/jprov/server/http.go b/jprov/server/http.go index 36e3cde..089d52d 100644 --- a/jprov/server/http.go +++ b/jprov/server/http.go @@ -60,17 +60,12 @@ func checkVersion(cmd *cobra.Command, w http.ResponseWriter, ctx *utils.Context) } chainID := clientCtx.ChainID - var v types.VersionResponse + v := types.VersionResponse{ + Version: version.Version, + ChainID: chainID, + } if len(res) > 0 { - v = types.VersionResponse{ - Version: res, - ChainID: chainID, - } - } else { - v = types.VersionResponse{ - Version: version.Version, - ChainID: chainID, - } + v.Version = res } err = json.NewEncoder(w).Encode(v)