diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a0bb8fa761a..ffc9b6afff4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -148,7 +148,28 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +<<<<<<< HEAD * (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration. +======= +* [#14691](https://github.com/cosmos/cosmos-sdk/pull/14691) Change behavior of `sdk.StringifyEvents` to not flatten events attributes by events type. + * This change only affects ABCI message logs, and not the actual events. +* [#14692](https://github.com/cosmos/cosmos-sdk/pull/14692) Improve RPC queries error message when app is at height 0. +* [#14609](https://github.com/cosmos/cosmos-sdk/pull/14609) Add RetryForBlocks method to use in tests that require waiting for a transaction to be included in a block. +* [#14017](https://github.com/cosmos/cosmos-sdk/pull/14017) Simplify ADR-028 and `address.Module`. + * This updates the [ADR-028](https://docs.cosmos.network/main/architecture/adr-028-public-key-addresses) and enhance the `address.Module` API to support module addresses and sub-module addresses in a backward compatible way. +* [#14529](https://github.com/cosmos/cosmos-sdk/pull/14529) Add new property `BondDenom` to `SimulationState` struct. +* (x/group, x/gov) [#14483](https://github.com/cosmos/cosmos-sdk/pull/14483) Add support for `[]string` and `[]int` in `draft-proposal` prompt. +* (protobuf) [#14476](https://github.com/cosmos/cosmos-sdk/pull/14476) Clean up protobuf annotations `{accepts,implements}_interface`. +* (module) [#14415](https://github.com/cosmos/cosmos-sdk/pull/14415) Loosen assertions in SetOrderBeginBlockers() and SetOrderEndBlockers() +* (context)[#14384](https://github.com/cosmos/cosmos-sdk/pull/14384) refactor(context): Pass EventManager to the context as an interface. +* (types) [#14354](https://github.com/cosmos/cosmos-sdk/pull/14354) - improve performance on Context.KVStore and Context.TransientStore by 40% +* (crypto/keyring) [#14151](https://github.com/cosmos/cosmos-sdk/pull/14151) Move keys presentation from `crypto/keyring` to `client/keys` +* (types) [#14163](https://github.com/cosmos/cosmos-sdk/pull/14163) Refactor `(coins Coins) Validate()` to avoid unnecessary map. +* (signing) [#14087](https://github.com/cosmos/cosmos-sdk/pull/14087) Add SignModeHandlerWithContext interface with a new `GetSignBytesWithContext` to get the sign bytes using `context.Context` as an argument to access state. +* (server) [#14062](https://github.com/cosmos/cosmos-sdk/pull/14062) Remove rosetta from server start. +* [13882] (https://github.com/cosmos/cosmos-sdk/pull/13882) Add tx `encode` and `decode` endpoints to amino tx service. + > Note: These endpoints encodes and decodes only amino txs. +>>>>>>> d5d39c053 (fix: do not flatten events attributes by event types (#14691)) * (x/nft) [#13836](https://github.com/cosmos/cosmos-sdk/pull/13836) Remove the validation for `classID` and `nftID` from the NFT module. * [#13789](https://github.com/cosmos/cosmos-sdk/pull/13789) Add tx `encode` and `decode` endpoints to tx service. > Note: These endpoints will only encode and decode proto messages, Amino encoding and decoding is not supported. diff --git a/math/dec_test.go b/math/dec_test.go index 45daeee77a13..a58ba7769db3 100644 --- a/math/dec_test.go +++ b/math/dec_test.go @@ -671,7 +671,7 @@ func BenchmarkLegacyQuoRoundupMut(b *testing.B) { func TestFormatDec(t *testing.T) { type decimalTest []string var testcases []decimalTest - raw, err := os.ReadFile("../tx/textual/internal/testdata/decimals.json") + raw, err := os.ReadFile("../x/tx/textual/internal/testdata/decimals.json") require.NoError(t, err) err = json.Unmarshal(raw, &testcases) require.NoError(t, err) diff --git a/math/int_test.go b/math/int_test.go index 5af450cb6c19..67b0fe4a26ce 100644 --- a/math/int_test.go +++ b/math/int_test.go @@ -432,7 +432,7 @@ func TestRoundTripMarshalToInt(t *testing.T) { func TestFormatInt(t *testing.T) { type integerTest []string var testcases []integerTest - raw, err := os.ReadFile("../tx/textual/internal/testdata/integers.json") + raw, err := os.ReadFile("../x/tx/textual/internal/testdata/integers.json") require.NoError(t, err) err = json.Unmarshal(raw, &testcases) require.NoError(t, err) diff --git a/types/events.go b/types/events.go index 0d8fafc02c5e..8e015d932d99 100644 --- a/types/events.go +++ b/types/events.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "reflect" - "sort" "strings" "golang.org/x/exp/maps" @@ -278,29 +277,6 @@ func (se StringEvents) String() string { return strings.TrimRight(sb.String(), "\n") } -// Flatten returns a flattened version of StringEvents by grouping all attributes -// per unique event type. -func (se StringEvents) Flatten() StringEvents { - flatEvents := make(map[string][]Attribute) - - for _, e := range se { - flatEvents[e.Type] = append(flatEvents[e.Type], e.Attributes...) - } - keys := make([]string, 0, len(flatEvents)) - res := make(StringEvents, 0, len(flatEvents)) // appeneded to keys, same length of what is allocated to keys - - for ty := range flatEvents { - keys = append(keys, ty) - } - - sort.Strings(keys) - for _, ty := range keys { - res = append(res, StringEvent{Type: ty, Attributes: flatEvents[ty]}) - } - - return res -} - // StringifyEvent converts an Event object to a StringEvent object. func StringifyEvent(e abci.Event) StringEvent { res := StringEvent{Type: e.Type} @@ -324,7 +300,7 @@ func StringifyEvents(events []abci.Event) StringEvents { res = append(res, StringifyEvent(e)) } - return res.Flatten() + return res } // MarkEventsToIndex returns the set of ABCI events, where each event's attribute diff --git a/types/events_test.go b/types/events_test.go index 966157d10158..3e48ca835b05 100644 --- a/types/events_test.go +++ b/types/events_test.go @@ -145,8 +145,8 @@ func (s *eventsTestSuite) TestStringifyEvents() { sdk.NewEvent("message", sdk.NewAttribute(sdk.AttributeKeySender, "foo")), sdk.NewEvent("message", sdk.NewAttribute(sdk.AttributeKeyModule, "bank")), }, - expTxtStr: "\t\t- message\n\t\t\t- sender: foo\n\t\t\t- module: bank", - expJSONStr: "[{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"foo\"},{\"key\":\"module\",\"value\":\"bank\"}]}]", + expTxtStr: "\t\t- message\n\t\t\t- sender: foo\n\t\t- message\n\t\t\t- module: bank", + expJSONStr: "[{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"foo\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"module\",\"value\":\"bank\"}]}]", }, { name: "multiple events with same attributes", @@ -158,8 +158,8 @@ func (s *eventsTestSuite) TestStringifyEvents() { ), sdk.NewEvent("message", sdk.NewAttribute(sdk.AttributeKeySender, "foo")), }, - expTxtStr: "\t\t- message\n\t\t\t- module: staking\n\t\t\t- sender: cosmos1foo\n\t\t\t- sender: foo", - expJSONStr: `[{"type":"message","attributes":[{"key":"module","value":"staking"},{"key":"sender","value":"cosmos1foo"},{"key":"sender","value":"foo"}]}]`, + expTxtStr: "\t\t- message\n\t\t\t- module: staking\n\t\t\t- sender: cosmos1foo\n\t\t- message\n\t\t\t- sender: foo", + expJSONStr: `[{"type":"message","attributes":[{"key":"module","value":"staking"},{"key":"sender","value":"cosmos1foo"}]},{"type":"message","attributes":[{"key":"sender","value":"foo"}]}]`, }, } diff --git a/types/result_test.go b/types/result_test.go index a58425c04a57..ccc6fe8575be 100644 --- a/types/result_test.go +++ b/types/result_test.go @@ -42,13 +42,17 @@ func (s *resultTestSuite) TestParseABCILog() { func (s *resultTestSuite) TestABCIMessageLog() { cdc := codec.NewLegacyAmino() - events := sdk.Events{sdk.NewEvent("transfer", sdk.NewAttribute("sender", "foo"))} + events := sdk.Events{ + sdk.NewEvent("transfer", sdk.NewAttribute("sender", "foo")), + sdk.NewEvent("transfer", sdk.NewAttribute("sender", "bar")), + } msgLog := sdk.NewABCIMessageLog(0, "", events) msgLogs := sdk.ABCIMessageLogs{msgLog} bz, err := cdc.MarshalJSON(msgLogs) s.Require().NoError(err) s.Require().Equal(string(bz), msgLogs.String()) + s.Require().Equal(`[{"msg_index":0,"events":[{"type":"transfer","attributes":[{"key":"sender","value":"foo"}]},{"type":"transfer","attributes":[{"key":"sender","value":"bar"}]}]}]`, msgLogs.String()) } func (s *resultTestSuite) TestNewSearchTxsResult() {