From bda51f23112ff4573f60f21d6b19fbbe0e113c3f Mon Sep 17 00:00:00 2001 From: Andrea Di Michele Date: Fri, 19 May 2023 14:41:07 +0000 Subject: [PATCH] fix: rawlog JSON formatting of proposal_vote option field (#16231) --- CHANGELOG.md | 1 + x/gov/types/v1/vote.go | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49d60ef0ab8e..79b22bfe139e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -245,6 +245,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/crypto) [#15258](https://github.com/cosmos/cosmos-sdk/pull/15258) Write keyhash file with permissions 0600 instead of 0555. * (cli) [#16138](https://github.com/cosmos/cosmos-sdk/pull/16138) Fix snapshot commands panic if snapshot don't exists. * (types) [#16145](https://github.com/cosmos/cosmos-sdk/pull/16145) Rename interface `ExtensionOptionI` back to `TxExtensionOptionI` to avoid breaking change. +* (x/gov) [#16230](https://github.com/cosmos/cosmos-sdk/pull/16231) Fix: rawlog JSON formatting of proposal_vote option field ### Deprecated diff --git a/x/gov/types/v1/vote.go b/x/gov/types/v1/vote.go index fe481eba9294..60a6b2756cc9 100644 --- a/x/gov/types/v1/vote.go +++ b/x/gov/types/v1/vote.go @@ -1,6 +1,7 @@ package v1 import ( + "encoding/json" "fmt" "strings" @@ -92,12 +93,9 @@ func ValidWeightedVoteOption(option WeightedVoteOption) bool { // WeightedVoteOptions describes array of WeightedVoteOptions type WeightedVoteOptions []*WeightedVoteOption -func (v WeightedVoteOptions) String() (out string) { - for _, opt := range v { - out += opt.String() + "\n" - } - - return strings.TrimSpace(out) +func (v WeightedVoteOptions) String() string { + out, _ := json.Marshal(v) + return string(out) } // VoteOptionFromString returns a VoteOption from a string. It returns an error