Skip to content

Commit

Permalink
chore: params cleanup (#12480)
Browse files Browse the repository at this point in the history
Adds missing error checks to the modules that migrated away from `x/params`
  • Loading branch information
alexanderbez authored Jul 8, 2022
1 parent 36ffd7a commit 69d8fa2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
11 changes: 5 additions & 6 deletions x/distribution/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"context"
"encoding/json"
"fmt"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"math/rand"

modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"

"cosmossdk.io/core/appmodule"
sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -22,14 +22,13 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
staking "github.com/cosmos/cosmos-sdk/x/staking/types"

modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
"github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/distribution/simulation"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
staking "github.com/cosmos/cosmos-sdk/x/staking/types"
)

var (
Expand Down
18 changes: 9 additions & 9 deletions x/gov/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@ package gov

import (
"context"
modulev1 "cosmossdk.io/api/cosmos/gov/module/v1"
"cosmossdk.io/core/appmodule"
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"math/rand"
"sort"

modulev1 "cosmossdk.io/api/cosmos/gov/module/v1"
"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
Expand All @@ -35,6 +34,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)

var (
Expand Down
6 changes: 5 additions & 1 deletion x/mint/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import (
// InitGenesis new mint genesis
func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) {
keeper.SetMinter(ctx, data.Minter)
keeper.SetParams(ctx, data.Params)

if err := keeper.SetParams(ctx, data.Params); err != nil {
panic(err)
}

ak.GetModuleAccount(ctx, types.ModuleName)
}

Expand Down
4 changes: 3 additions & 1 deletion x/slashing/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func (keeper Keeper) InitGenesis(ctx sdk.Context, stakingKeeper types.StakingKee
}
}

keeper.SetParams(ctx, data.Params)
if err := keeper.SetParams(ctx, data.Params); err != nil {
panic(err)
}
}

// ExportGenesis writes the current store values
Expand Down
14 changes: 6 additions & 8 deletions x/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@ import (
"math/rand"
"sort"

gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"golang.org/x/exp/maps"

modulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
"cosmossdk.io/core/appmodule"
"github.com/cosmos/cosmos-sdk/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"

gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"golang.org/x/exp/maps"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/staking/client/cli"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/simulation"
Expand Down

0 comments on commit 69d8fa2

Please sign in to comment.