Skip to content

Commit 18eea3a

Browse files
fix: fixed missing coin denomination in msg server logs (cosmos#9786)
<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: [cosmos#9785](cosmos#9785) This PR modifies _x/staking/keeper/msg_server.go_ file and fixes coin denomination issues in the emitted events. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [x] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [x] reviewed state machine logic - [x] reviewed API design and naming - [x] reviewed documentation is accurate - [x] reviewed tests and test coverage - [ ] manually tested (if applicable)
1 parent 7f316ad commit 18eea3a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
6969

7070
* [\#9594](https://github.com/cosmos/cosmos-sdk/pull/9594) Remove legacy REST API. Please see the [REST Endpoints Migration guide](https://docs.cosmos.network/master/migrations/rest.html) to migrate to the new REST endpoints.
7171
* [\#9781](https://github.com/cosmos/cosmos-sdk/pull/9781) Improve`withdraw-all-rewards` UX when broadcast mode `async` or `async` is used.
72-
72+
* [\#9785](https://github.com/cosmos/cosmos-sdk/issues/9785) Missing coin denomination in logs
7373

7474
### CLI Breaking Changes
7575

x/staking/client/testutil/suite.go

+9
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
212212
txResp := tc.respType.(*sdk.TxResponse)
213213
require.Equal(tc.expectedCode, txResp.Code,
214214
"test: %s, output\n:", tc.name, out.String())
215+
216+
events := txResp.Logs[0].GetEvents()
217+
for i := 0; i < len(events); i++ {
218+
if events[i].GetType() == "create_validator" {
219+
attributes := events[i].GetAttributes()
220+
require.Equal(attributes[1].Value, "100stake")
221+
break
222+
}
223+
}
215224
}
216225
})
217226
}

x/staking/keeper/msg_server.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa
112112
sdk.NewEvent(
113113
types.EventTypeCreateValidator,
114114
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
115-
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Value.Amount.String()),
115+
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Value.String()),
116116
),
117117
sdk.NewEvent(
118118
sdk.EventTypeMessage,
@@ -235,7 +235,7 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ
235235
sdk.NewEvent(
236236
types.EventTypeDelegate,
237237
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
238-
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()),
238+
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
239239
sdk.NewAttribute(types.AttributeKeyNewShares, newShares.String()),
240240
),
241241
sdk.NewEvent(
@@ -301,7 +301,7 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed
301301
types.EventTypeRedelegate,
302302
sdk.NewAttribute(types.AttributeKeySrcValidator, msg.ValidatorSrcAddress),
303303
sdk.NewAttribute(types.AttributeKeyDstValidator, msg.ValidatorDstAddress),
304-
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()),
304+
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
305305
sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)),
306306
),
307307
sdk.NewEvent(
@@ -362,7 +362,7 @@ func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (
362362
sdk.NewEvent(
363363
types.EventTypeUnbond,
364364
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
365-
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()),
365+
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
366366
sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)),
367367
),
368368
sdk.NewEvent(

0 commit comments

Comments
 (0)