From 8fb074f8ee966e97345d1d6ab7a8d17a967da8d6 Mon Sep 17 00:00:00 2001 From: antstalepresh Date: Wed, 21 Feb 2024 08:28:50 +0800 Subject: [PATCH 1/2] alliance sdk50 support --- app/app.go | 114 +++++++++++++++++++++++++++-------------------------- go.mod | 6 +-- go.sum | 6 +++ 3 files changed, 67 insertions(+), 59 deletions(-) diff --git a/app/app.go b/app/app.go index 82916ee5..fe624923 100644 --- a/app/app.go +++ b/app/app.go @@ -52,8 +52,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" - bank "github.com/cosmos/cosmos-sdk/x/bank" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + + // bank "github.com/cosmos/cosmos-sdk/x/bank" + // bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" @@ -90,12 +91,11 @@ import ( capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" - // bank "github.com/terra-money/alliance/custom/bank" - // bankkeeper "github.com/terra-money/alliance/custom/bank/keeper" - // alliancemodule "github.com/terra-money/alliance/x/alliance" - // alliancemoduleclient "github.com/terra-money/alliance/x/alliance/client" - // alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper" - // alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types" + bank "github.com/terra-money/alliance/custom/bank" + bankkeeper "github.com/terra-money/alliance/custom/bank/keeper" + alliancemodule "github.com/terra-money/alliance/x/alliance" + alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper" + alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types" "cosmossdk.io/x/upgrade" upgradekeeper "cosmossdk.io/x/upgrade/keeper" @@ -173,23 +173,23 @@ var ( // module account permissions maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - ibcfeetypes.ModuleName: nil, - icatypes.ModuleName: nil, - wasmtypes.ModuleName: {authtypes.Burner}, - denomtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - batchtypes.ModuleName: nil, - schedulertypes.ModuleName: nil, - oracletypes.ModuleName: nil, - // alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - // alliancemoduletypes.RewardsPoolName: nil, - cwicatypes.ModuleName: nil, + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibcfeetypes.ModuleName: nil, + icatypes.ModuleName: nil, + wasmtypes.ModuleName: {authtypes.Burner}, + denomtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + batchtypes.ModuleName: nil, + schedulertypes.ModuleName: nil, + oracletypes.ModuleName: nil, + alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + alliancemoduletypes.RewardsPoolName: nil, + cwicatypes.ModuleName: nil, } ) @@ -251,7 +251,7 @@ type App struct { SchedulerKeeper schedulerkeeper.Keeper OracleKeeper oraclekeeper.Keeper CwICAKeeper cwicakeeper.Keeper - // AllianceKeeper alliancemodulekeeper.Keeper + AllianceKeeper alliancemodulekeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -368,7 +368,7 @@ func New( schedulertypes.StoreKey, oracletypes.StoreKey, batchtypes.StoreKey, - // AllianceStoreKey, + AllianceStoreKey, cwicatypes.StoreKey, ) @@ -473,18 +473,18 @@ func New( authority, ) - // app.AllianceKeeper = alliancemodulekeeper.NewKeeper( - // appCodec, - // keys[AllianceStoreKey], - // app.AccountKeeper, - // app.BankKeeper, - // app.StakingKeeper, - // app.DistrKeeper, - // authtypes.FeeCollectorName, - // authority, - // ) + app.AllianceKeeper = alliancemodulekeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[AllianceStoreKey]), + app.AccountKeeper, + app.BankKeeper, + app.StakingKeeper, + app.DistrKeeper, + authtypes.FeeCollectorName, + authority, + ) - // app.BankKeeper.RegisterKeepers(app.AllianceKeeper, app.StakingKeeper) + app.BankKeeper.RegisterKeepers(app.AllianceKeeper, app.StakingKeeper) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, @@ -528,8 +528,10 @@ func New( // register the staking hooks app.StakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), // app.AllianceKeeper.StakingHooks(), - + stakingtypes.NewMultiStakingHooks( + app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), + app.AllianceKeeper.StakingHooks(), + ), ) // ... other modules keepers @@ -699,8 +701,8 @@ func New( // See: https://docs.cosmos.network/main/modules/gov#proposal-messages govRouter := govtypesv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) - // AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(app.AllianceKeeper)) + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). + AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(app.AllianceKeeper)) // Create evidence Keeper for to register the IBC light client misbehaviour evidence route evidenceKeeper := evidencekeeper.NewKeeper( @@ -924,15 +926,15 @@ func New( app.BankKeeper, ), - // alliancemodule.NewAppModule( - // appCodec, - // app.AllianceKeeper, - // app.StakingKeeper, - // app.AccountKeeper, - // app.BankKeeper, - // app.interfaceRegistry, - // app.GetSubspace(alliancemoduletypes.ModuleName), - // ), + alliancemodule.NewAppModule( + appCodec, + app.AllianceKeeper, + app.StakingKeeper, + app.AccountKeeper, + app.BankKeeper, + app.interfaceRegistry, + app.GetSubspace(alliancemoduletypes.ModuleName), + ), cwica.NewAppModule(appCodec, app.CwICAKeeper), @@ -996,7 +998,7 @@ func New( schedulertypes.ModuleName, oracletypes.ModuleName, cwicatypes.ModuleName, - // alliancemoduletypes.ModuleName, + alliancemoduletypes.ModuleName, ) app.ModuleManager.SetOrderEndBlockers( @@ -1028,7 +1030,7 @@ func New( schedulertypes.ModuleName, oracletypes.ModuleName, cwicatypes.ModuleName, - // alliancemoduletypes.ModuleName, + alliancemoduletypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -1065,7 +1067,7 @@ func New( batchtypes.ModuleName, schedulertypes.ModuleName, oracletypes.ModuleName, - // alliancemoduletypes.ModuleName, + alliancemoduletypes.ModuleName, wasmtypes.ModuleName, cwicatypes.ModuleName, ) @@ -1188,7 +1190,7 @@ func BlockedAddresses() map[string]bool { // allow the following addresses to receive funds delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String()) - // delete(modAccAddrs, authtypes.NewModuleAddress(alliancemoduletypes.ModuleName).String()) + delete(modAccAddrs, authtypes.NewModuleAddress(alliancemoduletypes.ModuleName).String()) delete(modAccAddrs, authtypes.NewModuleAddress(authtypes.FeeCollectorName).String()) return modAccAddrs @@ -1411,7 +1413,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(schedulertypes.ModuleName) paramsKeeper.Subspace(oracletypes.ModuleName) paramsKeeper.Subspace(batchtypes.ModuleName) - // paramsKeeper.Subspace(alliancemoduletypes.ModuleName) + paramsKeeper.Subspace(alliancemoduletypes.ModuleName) return paramsKeeper } diff --git a/go.mod b/go.mod index 99b83b3a..b86fb957 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.8.4 - // github.com/terra-money/alliance v0.3.2 + github.com/terra-money/alliance v0.3.4-0.20240219082352-93675c5a81f3 google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f google.golang.org/grpc v1.60.1 gopkg.in/yaml.v2 v2.4.0 @@ -45,7 +45,7 @@ require ( cosmossdk.io/x/upgrade v0.1.0 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/ibc-go/modules/capability v1.0.0 - github.com/hashicorp/go-metrics v0.5.1 + github.com/hashicorp/go-metrics v0.5.2 ) require ( @@ -123,7 +123,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.1 // indirect + github.com/hashicorp/go-getter v1.7.3 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-plugin v1.5.2 // indirect diff --git a/go.sum b/go.sum index b95b9cd3..7d1ac2f2 100644 --- a/go.sum +++ b/go.sum @@ -664,6 +664,8 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.3 h1:bN2+Fw9XPFvOCjB0UOevFIMICZ7G2XSQHzfvLUyOM5E= +github.com/hashicorp/go-getter v1.7.3/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -671,6 +673,8 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U= github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= +github.com/hashicorp/go-metrics v0.5.2 h1:ErEYO2f//CjKsUDw4SmLzelsK6L3ZmOAR/4P9iS7ruY= +github.com/hashicorp/go-metrics v0.5.2/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= @@ -1024,6 +1028,8 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/terra-money/alliance v0.3.4-0.20240219082352-93675c5a81f3 h1:xFwEQVkpeJQvdhkcd9m77Ey5S/OnQodT1b5E9GYXXvM= +github.com/terra-money/alliance v0.3.4-0.20240219082352-93675c5a81f3/go.mod h1:JEvSCfNEqepLIsvLYuaD2+XrT5hP26Bpqg8qbtaW5Bc= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= From 1096fdf4bcdfcfc8178ca8313a0feddcd6ba12f1 Mon Sep 17 00:00:00 2001 From: antstalepresh Date: Wed, 21 Feb 2024 08:31:23 +0800 Subject: [PATCH 2/2] go mod tidy --- go.sum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/go.sum b/go.sum index 7d1ac2f2..2376fd62 100644 --- a/go.sum +++ b/go.sum @@ -662,8 +662,6 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= -github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-getter v1.7.3 h1:bN2+Fw9XPFvOCjB0UOevFIMICZ7G2XSQHzfvLUyOM5E= github.com/hashicorp/go-getter v1.7.3/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= @@ -671,8 +669,6 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U= -github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-metrics v0.5.2 h1:ErEYO2f//CjKsUDw4SmLzelsK6L3ZmOAR/4P9iS7ruY= github.com/hashicorp/go-metrics v0.5.2/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=