From cfd2745da298866151a5ded885c5ed58cebae598 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 11:42:22 +0200 Subject: [PATCH] fix: change ordering of events when submitting a bundle (backport #42) (#43) Co-authored-by: Maximilian Breithecker <72022235+mbreithecker@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ x/bundles/keeper/logic_bundles.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f04c97eb..922627db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ ## [Unreleased] +### API Breaking + +- (`x/bundles`) [#42](https://github.com/KYVENetwork/chain/pull/42) Emit `VoteEvent` after `BundleProposedEvent` when submitting a bundle. + ## [v1.1.1](https://github.com/KYVENetwork/chain/releases/tag/v1.1.1) - 2023-05-08 ### Improvements diff --git a/x/bundles/keeper/logic_bundles.go b/x/bundles/keeper/logic_bundles.go index f76540d0..0dd245b0 100644 --- a/x/bundles/keeper/logic_bundles.go +++ b/x/bundles/keeper/logic_bundles.go @@ -280,14 +280,6 @@ func (k Keeper) registerBundleProposalFromUploader(ctx sdk.Context, msg *types.M CompressionId: pool.CurrentCompressionId, } - // Emit a vote event. - _ = ctx.EventManager().EmitTypedEvent(&types.EventBundleVote{ - PoolId: msg.PoolId, - Staker: msg.Staker, - StorageId: msg.StorageId, - Vote: types.VOTE_TYPE_VALID, - }) - k.SetBundleProposal(ctx, bundleProposal) _ = ctx.EventManager().EmitTypedEvent(&types.EventBundleProposed{ @@ -306,6 +298,14 @@ func (k Keeper) registerBundleProposalFromUploader(ctx sdk.Context, msg *types.M StorageProviderId: bundleProposal.StorageProviderId, CompressionId: bundleProposal.CompressionId, }) + + // Emit a vote event. Uploader automatically votes valid on their bundle. + _ = ctx.EventManager().EmitTypedEvent(&types.EventBundleVote{ + PoolId: msg.PoolId, + Staker: msg.Staker, + StorageId: msg.StorageId, + Vote: types.VOTE_TYPE_VALID, + }) } // finalizeCurrentBundleProposal takes the data of the current evaluated proposal