Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixes violations of the linter rules on an empty scaffolded chain #4441

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,37 @@ func initAppForTestnet(app *app.App, args valArgs) *app.App {
iterator.Close()

// Add our validator to power and last validators store
app.StakingKeeper.SetValidator(ctx, newVal)
err = app.StakingKeeper.SetValidatorByConsAddr(ctx, newVal)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
app.StakingKeeper.SetValidatorByPowerIndex(ctx, newVal)
app.StakingKeeper.SetLastValidatorPower(ctx, validator, 0)
if err := app.StakingKeeper.Hooks().AfterValidatorCreated(ctx, validator); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

handleErr(app.StakingKeeper.SetValidator(ctx, newVal))
handleErr(app.StakingKeeper.SetValidatorByConsAddr(ctx, newVal))
handleErr(app.StakingKeeper.SetValidatorByPowerIndex(ctx, newVal))
handleErr(app.StakingKeeper.SetLastValidatorPower(ctx, validator, 0))
handleErr(app.StakingKeeper.Hooks().AfterValidatorCreated(ctx, validator))

// DISTRIBUTION
//

// Initialize records for this validator across all distribution stores
app.DistrKeeper.ValidatorHistoricalRewards.Set(ctx, collections.Join(sdk.ValAddress(validator), uint64(0)), distrtypes.NewValidatorHistoricalRewards(sdk.DecCoins{}, 1))
app.DistrKeeper.ValidatorCurrentRewards.Set(ctx, validator, distrtypes.NewValidatorCurrentRewards(sdk.DecCoins{}, 1))
app.DistrKeeper.ValidatorsAccumulatedCommission.Set(ctx, validator, distrtypes.InitialValidatorAccumulatedCommission())
app.DistrKeeper.ValidatorOutstandingRewards.Set(ctx, validator, distrtypes.ValidatorOutstandingRewards{Rewards: sdk.DecCoins{}})
handleErr(app.DistrKeeper.ValidatorHistoricalRewards.Set(
ctx,
collections.Join(sdk.ValAddress(validator), uint64(0)),
distrtypes.NewValidatorHistoricalRewards(sdk.DecCoins{}, 1),
))

handleErr(app.DistrKeeper.ValidatorCurrentRewards.Set(
ctx,
validator,
distrtypes.NewValidatorCurrentRewards(sdk.DecCoins{}, 1),
))

handleErr(app.DistrKeeper.ValidatorsAccumulatedCommission.Set(
ctx, validator, distrtypes.InitialValidatorAccumulatedCommission(),
))

handleErr(app.DistrKeeper.ValidatorOutstandingRewards.Set(
ctx,
validator,
distrtypes.ValidatorOutstandingRewards{Rewards: sdk.DecCoins{}},
))

<%= if (!IsChainMinimal) { %>
// SLASHING
Expand All @@ -204,7 +214,6 @@ func initAppForTestnet(app *app.App, args valArgs) *app.App {

defaultCoins := sdk.NewCoins(sdk.NewInt64Coin(bondDenom, 1000000000))

// Fund local accounts
// Fund local accounts
for _, accountStr := range args.accountsToFund {
err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, defaultCoins)
Expand Down Expand Up @@ -267,3 +276,11 @@ func getCommandArgs(appOpts servertypes.AppOptions) (valArgs, error) {

return args, nil
}

// handleErr prints the error and exits the program if the error is not nil
func handleErr(err error) {
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
Loading