Skip to content

Commit

Permalink
feat: integrate with v0.52.x (3/n)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 28, 2024
1 parent 37ac324 commit 564a2a5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ type ModuleInputs struct {
Cdc codec.Codec
AddressCodec address.Codec

AccountKeeper types.AccountKeeper
BankKeeper types.BankKeeper<%= for (dependency) in dependencies { %><%= if (dependency.Name != "Bank" && dependency.Name != "Account") { %>
<%= dependency.KeeperName() %> types.<%= dependency.KeeperName() %><% } %><% } %>
<%= for (dependency) in dependencies { %>
<%= dependency.KeeperName() %> types.<%= dependency.KeeperName() %><% } %>

<%= if (isIBC) { %>IBCKeeperFn func() *ibckeeper.Keeper `optional:"true"`
CapabilityScopedFn func(string) capabilitykeeper.ScopedKeeper `optional:"true"`<% } %>
Expand Down Expand Up @@ -68,12 +67,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
in.CapabilityScopedFn,<% } %><%= for (dependency) in dependencies { %>
in.<%= dependency.KeeperName() %>,<% } %>
)
m := NewAppModule(
in.Cdc,
k,
in.AccountKeeper,
in.BankKeeper,
)
m := NewAppModule(in.Cdc, k,)

return ModuleOutputs{<%= title(moduleName) %>Keeper: k, Module: m}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,17 @@ type AppModule struct {
cdc codec.Codec
keeper keeper.Keeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
}

func NewAppModule(
cdc codec.Codec,
keeper keeper.Keeper,
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
) AppModule {
return AppModule{
cdc: cdc,
keeper: keeper,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/cosmos/cosmos-sdk/simsx"

"<%= modulePath %>/testutil/sample"
<%= moduleName %>simulation "<%= modulePath %>/x/<%= moduleName %>/simulation"
"<%= modulePath %>/x/<%= moduleName %>/simulation"
"<%= modulePath %>/x/<%= moduleName %>/types"
)

// avoid unused import issue
var (
_ = <%= moduleName %>simulation.FindAccount
_ = rand.Rand{}
_ = sample.AccAddress
_ = sdk.AccAddress{}
_ = simulation.MsgEntryKind
)

const (
Expand All @@ -44,18 +42,14 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
// RegisterStoreDecoder registers a decoder.
func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {}

// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
operations := make([]simtypes.WeightedOperation, 0)
// ProposalMsgsX returns msgs used for governance proposals for simulations.
func (AppModule) ProposalMsgsX(weights simsx.WeightSource, reg simsx.Registry) {
reg.Add(weights.Get("msg_update_params", 100), simulation.MsgUpdateParamsFactory())

// this line is used by starport scaffolding # simapp/module/operation

return operations
// this line is used by starport scaffolding # simapp/module/OpMsg
}

// ProposalMsgs returns msgs used for governance proposals for simulations.
func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg {
return []simtypes.WeightedProposalMsg{
// this line is used by starport scaffolding # simapp/module/OpMsg
}
// WeightedOperations returns the all the module operations with their respective weights.
func (am AppModule) WeightedOperationsX(weights simsx.WeightSource, reg simsx.Registry) {
// this line is used by starport scaffolding # simapp/module/operation
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package simulation

import (
"context"

"github.com/cosmos/cosmos-sdk/simsx"
)

// MsgUpdateParamsFactory creates a gov proposal for param updates
func MsgUpdateParamsFactory() simsx.SimMsgFactoryFn[*types.MsgUpdateParams] {
return func(_ context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgUpdateParams) {
params := types.DefaultParams()
// add custom params here
return nil, &types.MsgUpdateParams{
Authority: testData.ModuleAccountAddress(reporter, "gov"),
Params: params,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ import (
)

<%= for (dependency) in dependencies { %>
<%= if (dependency.Name == "Account") { %>
<%= if (dependency.Name == "Auth") { %>
// AuthKeeper defines the expected interface for the Auth module.
type AuthKeeper interface {
GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // only used for simulation
// Methods imported from account should be defined here
}
<% } else if (dependency.Name == "Bank") { %>
// BankKeeper defines the expected interface for the Bank module.
type BankKeeper interface {
SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins
// Methods imported from bank should be defined here
}
<% } else if (dependency.Name == "Staking") { %>
// StakingKeeper defines the expected interface for the Staking module.
type StakingKeeper interface {
Expand Down Expand Up @@ -68,22 +78,4 @@ import (
// TODO Add methods imported from <%= toLower(dependency.Name) %> should be defined here
}
<% } %>
<% } %>

// AccountKeeper defines the expected interface for the Account module.
type AccountKeeper interface {
GetAccount(context.Context, sdk.AccAddress) sdk.AccountI // only used for simulation
// Methods imported from account should be defined here
}

// BankKeeper defines the expected interface for the Bank module.
type BankKeeper interface {
SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins
// Methods imported from bank should be defined here
}

// ParamSubspace defines the expected Subspace interface for parameters.
type ParamSubspace interface {
Get(context.Context, []byte, interface{})
Set(context.Context, []byte, interface{})
}
<% } %>

0 comments on commit 564a2a5

Please sign in to comment.