@@ -719,15 +719,90 @@ func (app *App) GetSubspace(moduleName string) paramstypes.Subspace {
719
719
}
720
720
721
721
func (app * App ) RegisterUpgradeHandlers (cfg module.Configurator ) {
722
+ const municipalInflationTargetAddress = "fetch1n8d5466h8he33uedc0vsgtahal0mrz55glre03"
723
+
724
+ // NOTE(pb): The `fetchd-v0.10.7` upgrade handler *MUST* be present due to the mainnent, where this is the *LAST*
725
+ // executed upgrade. Presence of this handler is enforced by the `x/upgrade/abci.go#L31-L40` (see the
726
+ // https://github.com/fetchai/cosmos-sdk/blob/09cf7baf4297a30acd8d09d9db7dd97d79ffe008/x/upgrade/abci.go#L31-L40).
727
+ app .UpgradeKeeper .SetUpgradeHandler ("fetchd-v0.10.7" , func (ctx sdk.Context , plan upgradetypes.Plan , fromVM module.VersionMap ) (module.VersionMap , error ) {
728
+ return app .mm .RunMigrations (ctx , cfg , fromVM )
729
+ })
730
+
731
+ // NOTE(pb): The `v0.11.2` upgrade handler *MUST* be present due to Dorado-1 testnet, where this is the *LAST*
732
+ // executed upgrade. Please see the details in the NOTE above.
722
733
app .UpgradeKeeper .SetUpgradeHandler ("v0.11.2" , func (ctx sdk.Context , plan upgradetypes.Plan , fromVM module.VersionMap ) (module.VersionMap , error ) {
723
734
mobixInfl , err := sdk .NewDecFromStr ("0.03" )
724
735
if err != nil {
725
736
return module.VersionMap {}, err
726
737
}
727
738
minter := app .MintKeeper .GetMinter (ctx )
728
739
minter .MunicipalInflation = []* minttypes.MunicipalInflationPair {
729
- {Denom : "nanomobx" , Inflation : minttypes .NewMunicipalInflation ("fetch1n8d5466h8he33uedc0vsgtahal0mrz55glre03" , mobixInfl )},
740
+ {Denom : "nanomobx" , Inflation : minttypes .NewMunicipalInflation (municipalInflationTargetAddress , mobixInfl )},
741
+ }
742
+
743
+ app .MintKeeper .SetMinter (ctx , minter )
744
+
745
+ return app .mm .RunMigrations (ctx , cfg , fromVM )
746
+ })
747
+
748
+ app .UpgradeKeeper .SetUpgradeHandler ("v0.11.3" , func (ctx sdk.Context , plan upgradetypes.Plan , fromVM module.VersionMap ) (module.VersionMap , error ) {
749
+ // Introducing the NOMX token **IF** it does not exist yet:
750
+ const nomxDenom = "nanonomx"
751
+ const nomxName = "NOMX"
752
+ const nomxSupply = 1000000000000000000 // = 10^18 < 2^63 (max(int64))
753
+ if ! app .BankKeeper .HasSupply (ctx , nomxDenom ) {
754
+ coinsToMint := sdk .NewCoins (sdk .NewInt64Coin (nomxDenom , nomxSupply ))
755
+ app .MintKeeper .MintCoins (ctx , coinsToMint )
756
+
757
+ acc , err := sdk .AccAddressFromBech32 (municipalInflationTargetAddress )
758
+ if err != nil {
759
+ panic (err )
760
+ }
761
+
762
+ err = app .BankKeeper .SendCoinsFromModuleToAccount (ctx , minttypes .ModuleName , acc , coinsToMint )
763
+ if err != nil {
764
+ panic (err )
765
+ }
766
+
767
+ ctx .EventManager ().EmitEvent (
768
+ sdk .NewEvent (
769
+ minttypes .EventTypeMunicipalMint ,
770
+ sdk .NewAttribute (minttypes .AttributeKeyDenom , nomxDenom ),
771
+ sdk .NewAttribute (minttypes .AttributeKeyTargetAddr , municipalInflationTargetAddress ),
772
+ sdk .NewAttribute (sdk .AttributeKeyAmount , coinsToMint .String ()),
773
+ ),
774
+ )
775
+
776
+ nomxMetadata := banktypes.Metadata {
777
+ Base : nomxDenom ,
778
+ Name : nomxName ,
779
+ Symbol : nomxName ,
780
+ Display : nomxName ,
781
+ Description : nomxName + " token" ,
782
+ DenomUnits : []* banktypes.DenomUnit {
783
+ {Denom : nomxName , Exponent : 9 , Aliases : nil },
784
+ {Denom : "mnomx" , Exponent : 6 , Aliases : nil },
785
+ {Denom : "unomx" , Exponent : 3 , Aliases : nil },
786
+ {Denom : nomxDenom , Exponent : 0 , Aliases : nil },
787
+ },
788
+ }
789
+
790
+ app .BankKeeper .SetDenomMetaData (ctx , nomxMetadata )
791
+ }
792
+
793
+ // Municipal Inflation for MOBX & NOMX tokens:
794
+ inflation , err := sdk .NewDecFromStr ("0.03" )
795
+ if err != nil {
796
+ return module.VersionMap {}, err
797
+ }
798
+
799
+ minter := app .MintKeeper .GetMinter (ctx )
800
+ municipalInflation := minttypes .NewMunicipalInflation (municipalInflationTargetAddress , inflation )
801
+ minter .MunicipalInflation = []* minttypes.MunicipalInflationPair {
802
+ {Denom : "nanomobx" , Inflation : municipalInflation },
803
+ {Denom : nomxDenom , Inflation : municipalInflation },
730
804
}
805
+
731
806
app .MintKeeper .SetMinter (ctx , minter )
732
807
733
808
return app .mm .RunMigrations (ctx , cfg , fromVM )
0 commit comments