Skip to content

Commit

Permalink
storetypes, ConsensusParams, test_helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Apr 28, 2023
1 parent 62d5df5 commit 4a164a6
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 26 deletions.
7 changes: 5 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ func NewAppKeepers(
appKeepers.tkeys[paramstypes.TStoreKey],
)

keys := appKeepers.GetKVStoreKey()

// set the BaseApp's parameter store
appKeepers.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())

Expand All @@ -189,7 +191,8 @@ func NewAppKeepers(
scopedWasmKeeper := appKeepers.CapabilityKeeper.ScopeToModule(wasm.ModuleName)

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
Bech32Prefix := "juno"
appKeepers.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
keys[authtypes.StoreKey],
authtypes.ProtoBaseAccount,
Expand Down Expand Up @@ -522,7 +525,7 @@ func NewAppKeepers(
}

// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName)
Expand Down
2 changes: 1 addition & 1 deletion app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var ModuleBasics = module.NewBasicManager(
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()...),
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
Expand Down
7 changes: 4 additions & 3 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
)

// Get flags every time the simulator is run
func init() {
simapp.GetSimulatorFlags()
simcli.GetSimulatorFlags()
}

type StoreKeysPrefixes struct {
A sdk.StoreKey
B sdk.StoreKey
A storetypes.StoreKey
B storetypes.StoreKey
Prefixes [][]byte
}

Expand Down
12 changes: 5 additions & 7 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/CosmWasm/wasmd/x/wasm"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
apphelpers "github.com/CosmosContracts/juno/v15/app/helpers"
appparams "github.com/CosmosContracts/juno/v15/app/params"
dbm "github.com/cometbft/cometbft-db"
Expand Down Expand Up @@ -129,12 +129,8 @@ func setup(withGenesis bool, invCheckPeriod uint) (*App, GenesisState) {
db,
nil,
true,
map[int64]bool{},
DefaultNodeHome,
invCheckPeriod,
encCdc,
GetEnabledProposals(),
EmptyBaseAppOptions{},
wasm.EnableAllProposals,
EmptyAppOptions{},
emptyWasmOpts,
)
if withGenesis {
Expand Down Expand Up @@ -188,6 +184,7 @@ func genesisStateWithValSet(t *testing.T,
defaultStParams.MaxEntries,
defaultStParams.HistoricalEntries,
appparams.BondDenom,
defaultStParams.MinCommissionRate, // 5%
)

// set validators and delegations
Expand Down Expand Up @@ -217,6 +214,7 @@ func genesisStateWithValSet(t *testing.T,
balances,
totalSupply,
[]banktypes.Metadata{},
banktypes.DefaultGenesisState().SendEnabled,
)

genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)
Expand Down
10 changes: 4 additions & 6 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ import (
"strings"

"github.com/CosmosContracts/juno/v15/app/keepers"
abci "github.com/cometbft/cometbft/abci/types"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// BaseAppParamManager defines an interrace that BaseApp is expected to fullfil
// that allows upgrade handlers to modify BaseApp parameters.
type BaseAppParamManager interface {
GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams
StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusParams)
}
// type BaseAppParamManager interface {
// GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams
// StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusParams)
// }

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
// must have written, in order for the state migration to go smoothly.
Expand Down
3 changes: 2 additions & 1 deletion osmoutils/noapptest/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

dbm "github.com/cometbft/cometbft-db"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
)

func CtxWithStoreKeys(keys []sdk.Store, header tmproto.Header, isCheckTx bool) sdk.Context {
Expand All @@ -25,7 +26,7 @@ func CtxWithStoreKeys(keys []sdk.Store, header tmproto.Header, isCheckTx bool) s
return sdk.NewContext(cms, header, isCheckTx, logger)
}

func DefaultCtxWithStoreKeys(storeKeys []sdk.StoreKey) sdk.Context {
func DefaultCtxWithStoreKeys(storeKeys []storetypes.StoreKey) sdk.Context {
header := tmproto.Header{Height: 1, ChainID: "osmoutils-test-1", Time: time.Now().UTC()}
deliverTx := false
return CtxWithStoreKeys(storeKeys, header, deliverTx)
Expand Down
5 changes: 3 additions & 2 deletions osmoutils/store_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/CosmosContracts/juno/v15/osmoutils"
"github.com/CosmosContracts/juno/v15/osmoutils/noapptest"
"github.com/CosmosContracts/juno/v15/osmoutils/osmoassert"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
)

// We need to setup a test suite with account keeper
Expand All @@ -30,7 +31,7 @@ type TestSuite struct {
ctx sdk.Context
store sdk.KVStore

authStoreKey sdk.StoreKey
authStoreKey storetypes.StoreKey
accountKeeper authkeeper.AccountKeeperI
}

Expand All @@ -43,7 +44,7 @@ func (suite *TestSuite) SetupTest() {
paramsKey := sdk.NewKVStoreKey(paramstypes.StoreKey)
paramsTKey := sdk.NewKVStoreKey(paramstypes.TStoreKey)
suite.ctx = noapptest.DefaultCtxWithStoreKeys(
[]sdk.StoreKey{customStoreKey, suite.authStoreKey, paramsKey, paramsTKey})
[]storetypes.StoreKey{customStoreKey, suite.authStoreKey, paramsKey, paramsTKey})
suite.store = suite.ctx.KVStore(customStoreKey)
// setup params (needed for auth)
encConfig := noapptest.MakeTestEncodingConfig(auth.AppModuleBasic{}, params.AppModuleBasic{})
Expand Down
5 changes: 3 additions & 2 deletions x/ibc-hooks/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ import (

"github.com/CosmosContracts/juno/v15/x/ibc-hooks/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type (
Keeper struct {
storeKey sdk.StoreKey
storeKey storetypes.StoreKey
}
)

// NewKeeper returns a new instance of the x/ibchooks keeper
func NewKeeper(
storeKey sdk.StoreKey,
storeKey storetypes.StoreKey,
) Keeper {
return Keeper{
storeKey: storeKey,
Expand Down
5 changes: 3 additions & 2 deletions x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
sdktypes "github.com/cosmos/cosmos-sdk/types"
)

// Keeper of the mint store
type Keeper struct {
cdc codec.BinaryCodec
storeKey sdk.StoreKey
storeKey sdktypes.StoreKey
paramSpace paramtypes.Subspace
stakingKeeper types.StakingKeeper
bankKeeper types.BankKeeper
Expand All @@ -22,7 +23,7 @@ type Keeper struct {

// NewKeeper creates a new mint Keeper instance
func NewKeeper(
cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
cdc codec.BinaryCodec, key sdktypes.StoreKey, paramSpace paramtypes.Subspace,
sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper,
feeCollectorName string,
) Keeper {
Expand Down

0 comments on commit 4a164a6

Please sign in to comment.