@@ -25,7 +25,6 @@ import (
25
25
"github.com/cosmos/cosmos-sdk/server/api"
26
26
"github.com/cosmos/cosmos-sdk/server/config"
27
27
servertypes "github.com/cosmos/cosmos-sdk/server/types"
28
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
29
28
sdk "github.com/cosmos/cosmos-sdk/types"
30
29
"github.com/cosmos/cosmos-sdk/types/module"
31
30
"github.com/cosmos/cosmos-sdk/version"
@@ -83,7 +82,6 @@ import (
83
82
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
84
83
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
85
84
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
86
- icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
87
85
icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host"
88
86
icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper"
89
87
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
@@ -721,163 +719,7 @@ func (app *App) GetSubspace(moduleName string) paramstypes.Subspace {
721
719
}
722
720
723
721
func (app * App ) RegisterUpgradeHandlers (cfg module.Configurator ) {
724
- upgradeInfo , err := app .UpgradeKeeper .ReadUpgradeInfoFromDisk ()
725
- if err != nil {
726
- panic (err )
727
- }
728
-
729
- if upgradeInfo .Name == "fetchd-v0.10.5" && ! app .UpgradeKeeper .IsSkipHeight (upgradeInfo .Height ) {
730
- storeUpgrades := storetypes.StoreUpgrades {
731
- Added : []string {icacontrollertypes .StoreKey , icahosttypes .StoreKey },
732
- }
733
-
734
- // configure store loader that checks if version == upgradeHeight and applies store upgrades
735
- app .SetStoreLoader (upgradetypes .UpgradeStoreLoader (upgradeInfo .Height , & storeUpgrades ))
736
- }
737
-
738
- app .UpgradeKeeper .SetUpgradeHandler ("fetchd-v0.10.5" , func (ctx sdk.Context , plan upgradetypes.Plan , fromVM module.VersionMap ) (module.VersionMap , error ) {
739
- // IBC migration sourced from: https://github.com/cosmos/ibc-go/blob/main/docs/migrations/support-denoms-with-slashes.md
740
-
741
- equalTraces := func (dtA , dtB ibctransfertypes.DenomTrace ) bool {
742
- return dtA .BaseDenom == dtB .BaseDenom && dtA .Path == dtB .Path
743
- }
744
-
745
- // list of traces that must replace the old traces in store
746
- var newTraces []ibctransfertypes.DenomTrace
747
- app .TransferKeeper .IterateDenomTraces (ctx ,
748
- func (dt ibctransfertypes.DenomTrace ) bool {
749
- // check if the new way of splitting FullDenom
750
- // into Trace and BaseDenom passes validation and
751
- // is the same as the current DenomTrace.
752
- // If it isn't then store the new DenomTrace in the list of new traces.
753
- newTrace := ibctransfertypes .ParseDenomTrace (dt .GetFullDenomPath ())
754
- if err := newTrace .Validate (); err == nil && ! equalTraces (newTrace , dt ) {
755
- newTraces = append (newTraces , newTrace )
756
- }
757
-
758
- return false
759
- })
760
-
761
- // replace the outdated traces with the new trace information
762
- for _ , nt := range newTraces {
763
- app .TransferKeeper .SetDenomTrace (ctx , nt )
764
- }
765
-
766
- // Add Interchain Accounts host module
767
- // set the ICS27 consensus version so InitGenesis is not run
768
- fromVM [icatypes .ModuleName ] = app .mm .Modules [icatypes .ModuleName ].ConsensusVersion ()
769
-
770
- // create ICS27 Controller submodule params, controller module not enabled.
771
- controllerParams := icacontrollertypes.Params {}
772
-
773
- // create ICS27 Host submodule params
774
- hostParams := icahosttypes.Params {
775
- HostEnabled : true ,
776
- AllowMessages : []string {
777
- sdk .MsgTypeURL (& banktypes.MsgSend {}),
778
- sdk .MsgTypeURL (& stakingtypes.MsgDelegate {}),
779
- sdk .MsgTypeURL (& stakingtypes.MsgBeginRedelegate {}),
780
- sdk .MsgTypeURL (& stakingtypes.MsgCreateValidator {}),
781
- sdk .MsgTypeURL (& stakingtypes.MsgEditValidator {}),
782
- sdk .MsgTypeURL (& distrtypes.MsgWithdrawDelegatorReward {}),
783
- sdk .MsgTypeURL (& distrtypes.MsgSetWithdrawAddress {}),
784
- sdk .MsgTypeURL (& distrtypes.MsgWithdrawValidatorCommission {}),
785
- sdk .MsgTypeURL (& distrtypes.MsgFundCommunityPool {}),
786
- sdk .MsgTypeURL (& govtypes.MsgVote {}),
787
- sdk .MsgTypeURL (& authz.MsgExec {}),
788
- sdk .MsgTypeURL (& authz.MsgGrant {}),
789
- sdk .MsgTypeURL (& authz.MsgRevoke {}),
790
- },
791
- }
792
-
793
- // initialize ICS27 module
794
- icamodule , correctTypecast := app .mm .Modules [icatypes .ModuleName ].(ica.AppModule )
795
- if ! correctTypecast {
796
- panic ("mm.Modules[icatypes.ModuleName] is not of type ica.AppModule" )
797
- }
798
- icamodule .InitModule (ctx , controllerParams , hostParams )
799
-
800
- validDenoms := map [string ]banktypes.Metadata {
801
- "atestfet" : {
802
- Base : "atestfet" ,
803
- Description : "Fetch-ai Network testnet token" ,
804
- DenomUnits : []* banktypes.DenomUnit {
805
- {Denom : "TESTFET" , Exponent : 18 },
806
- {Denom : "mtestfet" , Exponent : 15 },
807
- {Denom : "utestfet" , Exponent : 12 },
808
- {Denom : "ntestfet" , Exponent : 9 },
809
- {Denom : "ptestfet" , Exponent : 6 },
810
- {Denom : "ftestfet" , Exponent : 3 },
811
- {Denom : "atestfet" , Exponent : 0 },
812
- },
813
- Display : "TESTFET" ,
814
- Name : "TESTFET" ,
815
- Symbol : "TESTFET" ,
816
- },
817
- "afet" : {
818
- Base : "afet" ,
819
- Description : "Fetch-ai Network token" ,
820
- DenomUnits : []* banktypes.DenomUnit {
821
- {Denom : "FET" , Exponent : 18 },
822
- {Denom : "mfet" , Exponent : 15 },
823
- {Denom : "ufet" , Exponent : 12 },
824
- {Denom : "nfet" , Exponent : 9 },
825
- {Denom : "pfet" , Exponent : 6 },
826
- {Denom : "ffet" , Exponent : 3 },
827
- {Denom : "afet" , Exponent : 0 },
828
- },
829
- Display : "FET" ,
830
- Name : "FET" ,
831
- Symbol : "FET" ,
832
- },
833
- "nanomobx" : {
834
- Base : "nanomobx" ,
835
- Description : "MOBIX Token" ,
836
- DenomUnits : []* banktypes.DenomUnit {
837
- {Denom : "MOBX" , Exponent : 9 },
838
- {Denom : "mmobx" , Exponent : 6 },
839
- {Denom : "umobx" , Exponent : 3 },
840
- {Denom : "nanomobx" , Exponent : 0 },
841
- },
842
- Display : "MOBX" ,
843
- Name : "MOBX" ,
844
- Symbol : "MOBX" ,
845
- },
846
- "nanonomx" : {
847
- Base : "nanonomx" ,
848
- Description : "NOMIX Token" ,
849
- DenomUnits : []* banktypes.DenomUnit {
850
- {Denom : "NOMX" , Exponent : 9 },
851
- {Denom : "mnomx" , Exponent : 6 },
852
- {Denom : "unomx" , Exponent : 3 },
853
- {Denom : "nanonomx" , Exponent : 0 },
854
- },
855
- Display : "NOMX" ,
856
- Name : "NOMX" ,
857
- Symbol : "NOMX" ,
858
- },
859
- "ulrn" : {
860
- Base : "ulrn" ,
861
- Description : "CoLearn Token" ,
862
- DenomUnits : []* banktypes.DenomUnit {
863
- {Denom : "lrn" , Exponent : 6 },
864
- {Denom : "mlrn" , Exponent : 3 },
865
- {Denom : "ulrn" , Exponent : 0 },
866
- },
867
- Display : "lrn" ,
868
- Name : "lrn" ,
869
- Symbol : "LRN" ,
870
- },
871
- }
872
-
873
- app .BankKeeper .IterateTotalSupply (ctx , func (c sdk.Coin ) bool {
874
- metas , ok := validDenoms [c .Denom ]
875
- if ok {
876
- app .BankKeeper .SetDenomMetaData (ctx , metas )
877
- }
878
- return false // iterate stop when callback return true
879
- })
880
-
722
+ app .UpgradeKeeper .SetUpgradeHandler ("fetchd-v0.10.7" , func (ctx sdk.Context , plan upgradetypes.Plan , fromVM module.VersionMap ) (module.VersionMap , error ) {
881
723
return app .mm .RunMigrations (ctx , cfg , fromVM )
882
724
})
883
725
}
0 commit comments