Skip to content

Commit

Permalink
fix(templates): fix lint errors in scaffolded chain (#3958)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Feb 12, 2024
1 parent 016c66d commit 7788834
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
24 changes: 17 additions & 7 deletions ignite/templates/app/files/app/export.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
/* Handle staking state. */

// iterate through redelegations, reset creation height
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
Expand All @@ -177,9 +177,12 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
}
return false
})

if err != nil {
panic(err)
}

// iterate through unbonding delegations, reset creation height
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
Expand All @@ -189,6 +192,9 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
}
return false
})
if err != nil {
panic(err)
}

// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
Expand All @@ -208,7 +214,9 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
validator.Jailed = true
}

app.StakingKeeper.SetValidator(ctx, validator)
if err := app.StakingKeeper.SetValidator(ctx, validator); err != nil {
panic(err)
}
counter++
}

Expand All @@ -226,13 +234,15 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
/* Handle slashing state. */

// reset start height on signing infos
app.SlashingKeeper.IterateValidatorSigningInfos(
if err := app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
_ = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
return false
},
)
); err != nil {
log.Fatal(err)
}
<% } %>
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) {
set := func(s *pflag.FlagSet, key, val string) {
if f := s.Lookup(key); f != nil {
f.DefValue = val
f.Value.Set(val)
_ = f.Value.Set(val)
}
}
for key, val := range defaults {
Expand Down
2 changes: 1 addition & 1 deletion ignite/templates/app/files/docs/docs.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func handler(title string) http.HandlerFunc {
t, _ := httptemplate.ParseFS(template, indexFile)

return func(w http.ResponseWriter, req *http.Request) {
t.Execute(w, struct {
_ = t.Execute(w, struct {
Title string
URL string
}{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func <%= title(moduleName) %>Keeper(t testing.TB) (keeper.Keeper, sdk.Context) {
ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger())

// Initialize params
k.SetParams(ctx, types.DefaultParams())
if err := k.SetParams(ctx, types.DefaultParams()); err != nil {
panic(err)
}

return k, ctx
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// InitGenesis initializes the module's state from a provided genesis state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
// this line is used by starport scaffolding # genesis/module/init
k.SetParams(ctx, genState.Params)
if err := k.SetParams(ctx, genState.Params); err != nil {
panic(err)
}
}

// ExportGenesis returns the module's exported genesis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
// RegisterStoreDecoder registers a decoder.
func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {}

// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}

// 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func <%= title(moduleName) %>Keeper(t testing.TB) (keeper.Keeper, sdk.Context) {
ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger())

// Initialize params
k.SetParams(ctx, types.DefaultParams())
if err := k.SetParams(ctx, types.DefaultParams()); err != nil {
panic(err)
}

return k, ctx
}

0 comments on commit 7788834

Please sign in to comment.