From d1c3547d8ee5a7ac506247e8b10c0a12fcbf741d Mon Sep 17 00:00:00 2001 From: Kien Date: Mon, 25 Mar 2024 22:55:39 +0700 Subject: [PATCH] feat(x/gov): emit depositor in `proposal_deposit` event (#19853) --- x/gov/CHANGELOG.md | 1 + x/gov/keeper/deposit.go | 1 + x/gov/keeper/proposal.go | 1 + x/gov/types/events.go | 1 + 4 files changed, 4 insertions(+) diff --git a/x/gov/CHANGELOG.md b/x/gov/CHANGELOG.md index 94bc8b201fa7..4859161e7758 100644 --- a/x/gov/CHANGELOG.md +++ b/x/gov/CHANGELOG.md @@ -34,6 +34,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18532](https://github.com/cosmos/cosmos-sdk/pull/18532) Add proposal types to proposals. * [#18620](https://github.com/cosmos/cosmos-sdk/pull/18620) Add optimistic proposals. * [#18762](https://github.com/cosmos/cosmos-sdk/pull/18762) Add multiple choice proposals. +* [#19853](https://github.com/cosmos/cosmos-sdk/pull/19853) Emit `depositor` in `EventTypeProposalDeposit` and `proposal_type` in `EventTypeSubmitProposal` ### Improvements diff --git a/x/gov/keeper/deposit.go b/x/gov/keeper/deposit.go index fc05386ce8e2..18980698efe1 100644 --- a/x/gov/keeper/deposit.go +++ b/x/gov/keeper/deposit.go @@ -179,6 +179,7 @@ func (k Keeper) AddDeposit(ctx context.Context, proposalID uint64, depositorAddr if err := k.environment.EventService.EventManager(ctx).EmitKV( types.EventTypeProposalDeposit, + event.NewAttribute(types.AttributeKeyDepositor, depositorAddr.String()), event.NewAttribute(sdk.AttributeKeyAmount, depositAmount.String()), event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), ); err != nil { diff --git a/x/gov/keeper/proposal.go b/x/gov/keeper/proposal.go index 1e1b38e92bbd..3cf868689458 100644 --- a/x/gov/keeper/proposal.go +++ b/x/gov/keeper/proposal.go @@ -146,6 +146,7 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata if err := k.environment.EventService.EventManager(ctx).EmitKV( types.EventTypeSubmitProposal, + event.NewAttribute(types.AttributeKeyProposalType, proposalType.String()), event.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), event.NewAttribute(types.AttributeKeyProposalProposer, proposer.String()), event.NewAttribute(types.AttributeKeyProposalMessages, strings.Join(msgs, ",")), diff --git a/x/gov/types/events.go b/x/gov/types/events.go index f9b107ac355c..ca2a01d2cead 100644 --- a/x/gov/types/events.go +++ b/x/gov/types/events.go @@ -13,6 +13,7 @@ const ( AttributeKeyVoter = "voter" AttributeKeyOption = "option" AttributeKeyProposalID = "proposal_id" + AttributeKeyDepositor = "depositor" AttributeKeyProposalMessages = "proposal_messages" // Msg type_urls in the proposal AttributeKeyVotingPeriodStart = "voting_period_start" AttributeKeyProposalLog = "proposal_log" // log of proposal execution