Skip to content

Commit

Permalink
migrate goc cosmos#2
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Apr 12, 2023
1 parent 00cba5b commit a9d122e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(gov.ProvideKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
Expand Down
2 changes: 1 addition & 1 deletion app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(gov.ProvideKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/democracy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
icstestingutils "github.com/cosmos/interchain-security/testutil/ibc_testing"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
testutil "github.com/cosmos/interchain-security/testutil/integration"
Expand Down
3 changes: 2 additions & 1 deletion testutil/integration/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
Expand Down Expand Up @@ -139,6 +139,7 @@ type TestMintKeeper interface {
}

type TestGovKeeper interface {
// TODO fix methods here
GetDepositParams(ctx sdk.Context) govtypes.DepositParams
GetVotingParams(ctx sdk.Context) govtypes.VotingParams
SetVotingParams(ctx sdk.Context, votingParams govtypes.VotingParams)
Expand Down
20 changes: 11 additions & 9 deletions x/ccv/democracy/governance/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
gov "github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

const (
Expand All @@ -28,11 +30,11 @@ type AppModule struct {
gov.AppModule

keeper keeper.Keeper
isProposalWhitelisted func(govtypes.Content) bool
isProposalWhitelisted func(govv1beta1.Content) bool
}

// NewAppModule creates a new AppModule object using the native x/governance module AppModule constructor.
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak govtypes.AccountKeeper, bk govtypes.BankKeeper, isProposalWhitelisted func(govtypes.Content) bool) AppModule {
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak govtypes.AccountKeeper, bk govtypes.BankKeeper, isProposalWhitelisted func(govv1beta1.Content) bool) AppModule {
govAppModule := gov.NewAppModule(cdc, keeper, ak, bk)
return AppModule{
AppModule: govAppModule,
Expand All @@ -42,7 +44,7 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak govtypes.AccountKeep
}

func (am AppModule) EndBlock(ctx sdk.Context, request abci.RequestEndBlock) []abci.ValidatorUpdate {
am.keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal govtypes.Proposal) bool {
am.keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal govv1.Proposal) bool {
// if there are forbidden proposals in active proposals queue, refund deposit, delete votes for that proposal
// and delete proposal from all storages
deleteForbiddenProposal(ctx, am, proposal)
Expand All @@ -52,7 +54,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, request abci.RequestEndBlock) []ab
return am.AppModule.EndBlock(ctx, request)
}

func deleteForbiddenProposal(ctx sdk.Context, am AppModule, proposal govtypes.Proposal) {
func deleteForbiddenProposal(ctx sdk.Context, am AppModule, proposal govv1.Proposal) {
if am.isProposalWhitelisted(proposal.GetContent()) {
return
}
Expand All @@ -63,21 +65,21 @@ func deleteForbiddenProposal(ctx sdk.Context, am AppModule, proposal govtypes.Pr
// private and cannot be called directly from the overridden app module
am.keeper.Tally(ctx, proposal)

am.keeper.DeleteProposal(ctx, proposal.ProposalId)
am.keeper.RefundDeposits(ctx, proposal.ProposalId)
am.keeper.DeleteProposal(ctx, proposal.Id)
am.keeper.RefundAndDeleteDeposits(ctx, proposal.Id)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
govtypes.EventTypeActiveProposal,
sdk.NewAttribute(govtypes.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.ProposalId)),
sdk.NewAttribute(govtypes.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.Id)),
sdk.NewAttribute(govtypes.AttributeKeyProposalResult, AttributeValueProposalForbidden),
),
)

logger := am.keeper.Logger(ctx)
logger.Info(
"proposal is not whitelisted; deleted",
"proposal", proposal.ProposalId,
"proposal", proposal.Id,
"title", proposal.GetTitle(),
"total_deposit", proposal.TotalDeposit.String())
"total_deposit", proposal.TotalDeposit)
}
2 changes: 1 addition & 1 deletion x/ccv/provider/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/interchain-security/x/ccv/provider/types"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package provider
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/interchain-security/x/ccv/provider/keeper"
"github.com/cosmos/interchain-security/x/ccv/provider/types"
)
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/proposal_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
testkeeper "github.com/cosmos/interchain-security/testutil/keeper"
"github.com/cosmos/interchain-security/x/ccv/provider"
providertypes "github.com/cosmos/interchain-security/x/ccv/provider/types"
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// RegisterLegacyAminoCodec registers the necessary x/ibc transfer interfaces and concrete types
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ccvtypes "github.com/cosmos/interchain-security/x/ccv/types"
)
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/types/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
Expand Down

0 comments on commit a9d122e

Please sign in to comment.