Skip to content

Commit

Permalink
refactor gov hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaru Wang committed Sep 21, 2023
1 parent f193361 commit c2cb529
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions x/ccv/provider/keeper/gov_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ func (gh GovHooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) {
panic(fmt.Errorf("failed to unmarshal proposal content in gov hook: %w", err))
}

// if the proposal is not ConsumerAdditionProposal, return
// if the proposal is not ConsumerAdditionProposal, continue
if msgLegacyContent.Content.TypeUrl != "/interchain_security.ccv.provider.v1.ConsumerAdditionProposal" {
continue
}
// if the proposal is not ConsumerAdditionProposal, continue
var consAdditionProp types.ConsumerAdditionProposal
if err := proto.Unmarshal(msgLegacyContent.Content.Value, &consAdditionProp); err != nil {
return
continue
}

if consAdditionProp.ProposalType() == types.ProposalTypeConsumerAddition {
Expand All @@ -74,17 +78,20 @@ func (gh GovHooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID ui
if err != nil {
panic(fmt.Errorf("failed to unmarshal proposal content in gov hook: %w", err))
}
var consAdditionProp types.ConsumerAdditionProposal

if msgLegacyContent.Content.TypeUrl != "/interchain_security.ccv.provider.v1.ConsumerAdditionProposal" {
continue
}
var consAdditionProp types.ConsumerAdditionProposal
// if the proposal is not ConsumerAdditionProposal, return
if err := proto.Unmarshal(msgLegacyContent.Content.Value, &consAdditionProp); err != nil {
return
continue
}
if consAdditionProp.ProposalType() != types.ProposalTypeConsumerAddition {
return

if consAdditionProp.ProposalType() == types.ProposalTypeConsumerAddition {
gh.k.DeleteChainsInProposal(ctx, consAdditionProp.ChainId, proposalID)
}

gh.k.DeleteChainsInProposal(ctx, consAdditionProp.ChainId, proposalID)
}
}

Expand Down

0 comments on commit c2cb529

Please sign in to comment.