From a8cb919f13bf7a676952b08e052d04b523dd0ccb Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 29 Aug 2024 12:29:07 +0000 Subject: [PATCH 1/3] feat(x/bank): add origin address in event multisend (#21460) (cherry picked from commit 33c463ec278702765c380afa69714f1e1b141271) # Conflicts: # x/bank/keeper/keeper_test.go # x/bank/keeper/send.go --- x/bank/keeper/keeper_test.go | 21 +++++++++++++++++++++ x/bank/keeper/send.go | 10 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 4bb11862eb62..8f14fdeb6e49 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -1449,6 +1449,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { event2 := sdk.Event{ Type: banktypes.EventTypeTransfer, +<<<<<<< HEAD Attributes: []abci.EventAttribute{}, } event2.Attributes = append( @@ -1469,6 +1470,26 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { event3.Attributes = append( event3.Attributes, abci.EventAttribute{Key: sdk.AttributeKeyAmount, Value: newCoins2.String()}, +======= + Attributes: []coreevent.Attribute{}, + } + event1.Attributes = append( + event1.Attributes, + coreevent.Attribute{Key: banktypes.AttributeKeyRecipient, Value: acc2StrAddr}, + coreevent.Attribute{Key: sdk.AttributeKeySender, Value: acc0StrAddr}, + coreevent.Attribute{Key: sdk.AttributeKeyAmount, Value: newCoins.String()}, + ) + + event2 := coreevent.Event{ + Type: banktypes.EventTypeTransfer, + Attributes: []coreevent.Attribute{}, + } + event2.Attributes = append( + event2.Attributes, + coreevent.Attribute{Key: banktypes.AttributeKeyRecipient, Value: acc3StrAddr}, + coreevent.Attribute{Key: sdk.AttributeKeySender, Value: acc0StrAddr}, + coreevent.Attribute{Key: sdk.AttributeKeyAmount, Value: newCoins2.String()}, +>>>>>>> 33c463ec2 (feat(x/bank): add origin address in event multisend (#21460)) ) // events are shifted due to the funding account events require.Equal(abci.Event(event1), events[25]) diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index c8aad5446f3b..0421d8c4811d 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -181,6 +181,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input, return err } +<<<<<<< HEAD sdkCtx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeTransfer, @@ -197,6 +198,15 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input, if !accExists { defer telemetry.IncrCounter(1, "new", "account") k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, outAddress)) +======= + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeTransfer, + event.NewAttribute(types.AttributeKeyRecipient, out.Address), + event.NewAttribute(types.AttributeKeySender, input.Address), + event.NewAttribute(sdk.AttributeKeyAmount, out.Coins.String()), + ); err != nil { + return err +>>>>>>> 33c463ec2 (feat(x/bank): add origin address in event multisend (#21460)) } } From 61d41474827e408887d6d35c64a2e61f3b12cabf Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 29 Aug 2024 16:01:11 +0200 Subject: [PATCH 2/3] fix conflicts --- x/bank/keeper/keeper_test.go | 30 +++--------------------------- x/bank/keeper/send.go | 11 +---------- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 8f14fdeb6e49..325b471c8e56 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -1449,16 +1449,14 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { event2 := sdk.Event{ Type: banktypes.EventTypeTransfer, -<<<<<<< HEAD Attributes: []abci.EventAttribute{}, } event2.Attributes = append( event2.Attributes, abci.EventAttribute{Key: banktypes.AttributeKeyRecipient, Value: accAddrs[2].String()}, + abci.EventAttribute{Key: banktypes.AttributeKeySender, Value: accAddrs[0].String()}, + abci.EventAttribute{Key: sdk.AttributeKeyAmount, Value: newCoins.String()}, ) - event2.Attributes = append( - event2.Attributes, - abci.EventAttribute{Key: sdk.AttributeKeyAmount, Value: newCoins.String()}) event3 := sdk.Event{ Type: banktypes.EventTypeTransfer, Attributes: []abci.EventAttribute{}, @@ -1466,30 +1464,8 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { event3.Attributes = append( event3.Attributes, abci.EventAttribute{Key: banktypes.AttributeKeyRecipient, Value: accAddrs[3].String()}, - ) - event3.Attributes = append( - event3.Attributes, + abci.EventAttribute{Key: banktypes.AttributeKeySender, Value: accAddrs[0].String()}, abci.EventAttribute{Key: sdk.AttributeKeyAmount, Value: newCoins2.String()}, -======= - Attributes: []coreevent.Attribute{}, - } - event1.Attributes = append( - event1.Attributes, - coreevent.Attribute{Key: banktypes.AttributeKeyRecipient, Value: acc2StrAddr}, - coreevent.Attribute{Key: sdk.AttributeKeySender, Value: acc0StrAddr}, - coreevent.Attribute{Key: sdk.AttributeKeyAmount, Value: newCoins.String()}, - ) - - event2 := coreevent.Event{ - Type: banktypes.EventTypeTransfer, - Attributes: []coreevent.Attribute{}, - } - event2.Attributes = append( - event2.Attributes, - coreevent.Attribute{Key: banktypes.AttributeKeyRecipient, Value: acc3StrAddr}, - coreevent.Attribute{Key: sdk.AttributeKeySender, Value: acc0StrAddr}, - coreevent.Attribute{Key: sdk.AttributeKeyAmount, Value: newCoins2.String()}, ->>>>>>> 33c463ec2 (feat(x/bank): add origin address in event multisend (#21460)) ) // events are shifted due to the funding account events require.Equal(abci.Event(event1), events[25]) diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 0421d8c4811d..7deedf473e3d 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -181,11 +181,11 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input, return err } -<<<<<<< HEAD sdkCtx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeTransfer, sdk.NewAttribute(types.AttributeKeyRecipient, outAddress.String()), + sdk.NewAttribute(types.AttributeKeySender, input.Address), sdk.NewAttribute(sdk.AttributeKeyAmount, out.Coins.String()), ), ) @@ -198,15 +198,6 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input, if !accExists { defer telemetry.IncrCounter(1, "new", "account") k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, outAddress)) -======= - if err := k.EventService.EventManager(ctx).EmitKV( - types.EventTypeTransfer, - event.NewAttribute(types.AttributeKeyRecipient, out.Address), - event.NewAttribute(types.AttributeKeySender, input.Address), - event.NewAttribute(sdk.AttributeKeyAmount, out.Coins.String()), - ); err != nil { - return err ->>>>>>> 33c463ec2 (feat(x/bank): add origin address in event multisend (#21460)) } } From 7535d1d9704d5ca8000d0896ae3bcc954b433cbf Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 29 Aug 2024 16:02:05 +0200 Subject: [PATCH 3/3] cl --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd73d04d79d2..370c39b819bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (cli) [#20779](https://github.com/cosmos/cosmos-sdk/pull/20779) Added `module-hash-by-height` command to query and retrieve module hashes at a specified blockchain height, enhancing debugging capabilities. +### Improvements + +* (x/bank) [#21460](https://github.com/cosmos/cosmos-sdk/pull/21460) Added `Sender` attribute in `MsgMultiSend` event. + ### Bug Fixes * (baseapp) [#21256](https://github.com/cosmos/cosmos-sdk/pull/21256) Halt height will not commit the block indicated, meaning that if halt-height is set to 10, only blocks until 9 (included) will be committed. This is to go back to the original behavior before a change was introduced in v0.50.0.