From 067c05a366174375b798eaf52367b71a707a3a17 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Wed, 6 Oct 2021 00:04:44 -0500 Subject: [PATCH] Remove linear # of bech32 encodes introduced (#505) --- CHANGELOG.md | 5 +++++ x/incentives/keeper/gauge.go | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9198367fcf4..fda3a2ac5ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,11 +33,16 @@ Ref: https://keepachangelog.com/en/1.0.0/ --> # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +* Fix bug in incentives epoch distribution events, used to use raw address, now uses bech32 addr + ## [v4.0.0] * Significantly speedup epoch times diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index 8042e818e1f..bf9ff881edb 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -335,6 +335,7 @@ func (k Keeper) debugDistribute(ctx sdk.Context, gauge types.Gauge) (sdk.Coins, type distributionInfo struct { nextID int lockOwnerAddrToID map[string]int + idToBech32Addr []string idToDecodedAddr []sdk.AccAddress idToDistrCoins []sdk.Coins } @@ -343,6 +344,7 @@ func newDistributionInfo() distributionInfo { return distributionInfo{ nextID: 0, lockOwnerAddrToID: make(map[string]int), + idToBech32Addr: []string{}, idToDecodedAddr: []sdk.AccAddress{}, idToDistrCoins: []sdk.Coins{}, } @@ -360,6 +362,7 @@ func (d *distributionInfo) addLockRewards(lock lockuptypes.PeriodLock, rewards s if err != nil { return err } + d.idToBech32Addr = append(d.idToBech32Addr, lock.Owner) d.idToDecodedAddr = append(d.idToDecodedAddr, decodedOwnerAddr) d.idToDistrCoins = append(d.idToDistrCoins, rewards) } @@ -383,7 +386,7 @@ func (k Keeper) doDistributionSends(ctx sdk.Context, denom string, distrs distri sdk.NewEvent( types.TypeEvtDistribution, sdk.NewAttribute(types.AttributeLockedDenom, denom), - sdk.NewAttribute(types.AttributeReceiver, distrs.idToDecodedAddr[id].String()), + sdk.NewAttribute(types.AttributeReceiver, distrs.idToBech32Addr[id]), sdk.NewAttribute(types.AttributeAmount, distrs.idToDistrCoins[id].String()), ), })