-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove unnecessary update in the bet data
- Loading branch information
1 parent
300e283
commit 7aa89c1
Showing
1 changed file
with
0 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |