Skip to content

Commit

Permalink
- add upgrade handler back again
Browse files Browse the repository at this point in the history
  • Loading branch information
StrathCole committed May 14, 2024
1 parent 8c8100b commit 285d562
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/upgrades/v9/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v9

import (
"github.com/classic-terra/core/v3/app/upgrades"
taxexemptiontypes "github.com/classic-terra/core/v3/x/taxexemption/types"
store "github.com/cosmos/cosmos-sdk/store/types"
)

const UpgradeName = "v9"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV9UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
taxexemptiontypes.StoreKey,
},
},
}
41 changes: 41 additions & 0 deletions app/upgrades/v9/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package v9

import (
"github.com/classic-terra/core/v3/app/keepers"
"github.com/classic-terra/core/v3/app/upgrades"
treasurytypes "github.com/classic-terra/core/v3/x/treasury/types"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateV9UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ upgrades.BaseAppParamManager,
k *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(c sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// migrate old treasurykeeper tax exemption to new tax exemption keeper
// tax exemption keeper is now a module

// get old tax exemption keeper
sub := prefix.NewStore(c.KVStore(k.TreasuryKeeper.GetStoreKey()), treasurytypes.BurnTaxExemptionListPrefix)

intoZone := "Binance"

// iterate through all tax exemptions
iterator := sub.Iterator(nil, nil)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
// get tax exemption address
address := string(iterator.Key())

// add tax exemption address to new tax exemption keeper
k.TaxExemptionKeeper.AddTaxExemptionAddress(c, intoZone, address)
}

return mm.RunMigrations(c, cfg, fromVM)
}
}

0 comments on commit 285d562

Please sign in to comment.