forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add governance hooks * Update x/gov/types/hooks.go * fixed * Update x/gov/keeper/keeper.go * remove VoteOption from hooks * fix lint * remove depositAmount and add depositorAddr * fix lint * fix cosmosvisor? * sh -> gh * Apply suggestions from code review Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> Co-authored-by: ahmedaly113 <ahmedaly113@outlook.com> Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
- Loading branch information
1 parent
842b060
commit 26b99b4
Showing
10 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/gov/types" | ||
) | ||
|
||
// Implements GovHooks interface | ||
var _ types.GovHooks = Keeper{} | ||
|
||
// AfterProposalSubmission - call hook if registered | ||
func (keeper Keeper) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) { | ||
if keeper.hooks != nil { | ||
keeper.hooks.AfterProposalSubmission(ctx, proposalID) | ||
} | ||
} | ||
|
||
// AfterProposalDeposit - call hook if registered | ||
func (keeper Keeper) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositAddr sdk.AccAddress) { | ||
if keeper.hooks != nil { | ||
keeper.hooks.AfterProposalDeposit(ctx, proposalID, depositAddr) | ||
} | ||
} | ||
|
||
// AfterProposalVote - call hook if registered | ||
func (keeper Keeper) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) { | ||
if keeper.hooks != nil { | ||
keeper.hooks.AfterProposalVote(ctx, proposalID, voterAddr) | ||
} | ||
} | ||
|
||
// AfterProposalInactive - call hook if registered | ||
func (keeper Keeper) AfterProposalInactive(ctx sdk.Context, proposalID uint64) { | ||
if keeper.hooks != nil { | ||
keeper.hooks.AfterProposalInactive(ctx, proposalID) | ||
} | ||
} | ||
|
||
// AfterProposalActive - call hook if registered | ||
func (keeper Keeper) AfterProposalActive(ctx sdk.Context, proposalID uint64) { | ||
if keeper.hooks != nil { | ||
keeper.hooks.AfterProposalActive(ctx, proposalID) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
var _ GovHooks = MultiGovHooks{} | ||
|
||
// combine multiple governance hooks, all hook functions are run in array sequence | ||
type MultiGovHooks []GovHooks | ||
|
||
func NewMultiGovHooks(hooks ...GovHooks) MultiGovHooks { | ||
return hooks | ||
} | ||
|
||
func (h MultiGovHooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) { | ||
for i := range h { | ||
h[i].AfterProposalSubmission(ctx, proposalID) | ||
} | ||
} | ||
|
||
func (h MultiGovHooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) { | ||
for i := range h { | ||
h[i].AfterProposalDeposit(ctx, proposalID, depositorAddr) | ||
} | ||
} | ||
|
||
func (h MultiGovHooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) { | ||
for i := range h { | ||
h[i].AfterProposalVote(ctx, proposalID, voterAddr) | ||
} | ||
} | ||
func (h MultiGovHooks) AfterProposalInactive(ctx sdk.Context, proposalID uint64) { | ||
for i := range h { | ||
h[i].AfterProposalInactive(ctx, proposalID) | ||
} | ||
} | ||
func (h MultiGovHooks) AfterProposalActive(ctx sdk.Context, proposalID uint64) { | ||
for i := range h { | ||
h[i].AfterProposalActive(ctx, proposalID) | ||
} | ||
} |