Skip to content

Commit

Permalink
fix: remove unnecessary update in the bet data
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpioborn committed Nov 2, 2023
1 parent 300e283 commit 7aa89c1
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions app/upgrades/v2/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
package v2

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/sge-network/sge/app/keepers"
)

// betOddsTypeRemoval removes bet odds type from current state
func betOddsTypeRemoval(keepers *keepers.AppKeepers, ctx sdk.Context) {
oldBets, err := keepers.BetKeeper.GetBets(ctx)
if err != nil {
panic(err)
}

for _, old := range oldBets {
betID, found := keepers.BetKeeper.GetBetID(ctx, old.UID)
if !found {
panic(fmt.Errorf("bet id for the uid not found %s", old.UID))
}

keepers.BetKeeper.SetBet(ctx, old, betID.ID)
}
}

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
betOddsTypeRemoval(keepers, ctx)

return mm.RunMigrations(ctx, configurator, fromVM)
}
}

0 comments on commit 7aa89c1

Please sign in to comment.