-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c8100b
commit 285d562
Showing
2 changed files
with
60 additions
and
0 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 |
---|---|---|
@@ -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, | ||
}, | ||
}, | ||
} |
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 |
---|---|---|
@@ -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) | ||
} | ||
} |