Skip to content

Commit

Permalink
Merge pull request #315 from ComposableFi/endBlock-logic-to-perform-b…
Browse files Browse the repository at this point in the history
…atching

add logic to app module to batch delegation.
  • Loading branch information
RustNinja authored Dec 21, 2023
2 parents 81a2901 + fad57ec commit a290f32
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions custom/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
// AppModule wraps around the bank module and the bank keeper to return the right total supply
type AppModule struct {
stakingmodule.AppModule
keeper customstakingkeeper.Keeper
subspace exported.Subspace
keeper customstakingkeeper.Keeper
subspace exported.Subspace
msgServer stakingtypes.MsgServer
}

// NewAppModule creates a new AppModule object
Expand All @@ -30,6 +31,7 @@ func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKee
AppModule: stakingModule,
keeper: keeper,
subspace: ss,
msgServer: stakingkeeper.NewMsgServerImpl(&keeper.Keeper),
}
}

Expand Down Expand Up @@ -75,9 +77,15 @@ func (am AppModule) EndBlock(ctx sdk.Context, _abc abcitype.RequestEndBlock) []a
println("Delegator Address: ", delegation.DelegatorAddress)
println("Validator Address: ", delegation.ValidatorAddress)
fmt.Println("Amount", delegation.Amount.Amount)

msgDelegate := stakingtypes.MsgDelegate{DelegatorAddress: delegation.DelegatorAddress, ValidatorAddress: delegation.ValidatorAddress, Amount: delegation.Amount}
_, err := am.msgServer.Delegate(ctx, &msgDelegate)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

path flow from Begin/EndBlock to a panic call
if err != nil {
println("Error for Delegator Address: ", delegation.DelegatorAddress)
}

}

// am.keeper.Delegate()
ctx.EventManager().EmitEvent(
sdk.NewEvent(
"DequeueAllDelegation",
Expand Down

0 comments on commit a290f32

Please sign in to comment.