Skip to content

Commit

Permalink
add gravity hooks template
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Aug 16, 2021
1 parent 7dacc83 commit 8881053
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
23 changes: 12 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,6 @@ func New(
bApp.Trace(), // debug EVM based on Baseapp options
)

app.GravityKeeper = gravitykeeper.NewKeeper(
appCodec,
keys[gravitytypes.StoreKey],
app.GetSubspace(gravitytypes.ModuleName),
app.AccountKeeper,
stakingKeeper,
app.BankKeeper,
app.SlashingKeeper,
sdk.DefaultPowerReduction,
)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

app.CronosKeeper = *cronosmodulekeeper.NewKeeper(
Expand All @@ -419,6 +408,18 @@ func New(
&stakingKeeper, govRouter,
)

gravityKeeper := gravitykeeper.NewKeeper(
appCodec,
keys[gravitytypes.StoreKey],
app.GetSubspace(gravitytypes.ModuleName),
app.AccountKeeper,
app.StakingKeeper,
app.BankKeeper,
app.SlashingKeeper,
sdk.DefaultPowerReduction,
)
app.GravityKeeper = *gravityKeeper.SetHooks(&app.CronosKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
Expand Down
17 changes: 17 additions & 0 deletions x/cronos/keeper/hooks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package keeper

import sdk "github.com/cosmos/cosmos-sdk/types"

// TODO Implements GravityHooks interface
func (h Keeper) BeforeDelegationCreated(_ sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
}
func (h Keeper) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) {}
func (h Keeper) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) {}
func (h Keeper) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) {}
func (h Keeper) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) {}
func (h Keeper) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress) {}
func (h Keeper) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) {}
func (h Keeper) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
}
func (h Keeper) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
}

0 comments on commit 8881053

Please sign in to comment.