Skip to content

Commit

Permalink
add emitter flusher for MsgCancelProposal
Browse files Browse the repository at this point in the history
  • Loading branch information
nkitlabs committed Feb 10, 2025
1 parent 2f8ca92 commit b56eb71
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions flusher/flusher/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,29 @@ def handle_new_proposal(self, msg):
del msg["proposer"]
self.conn.execute(proposals.insert(), msg)

def handle_remove_proposal(self, msg):
self.conn.execute(proposals.delete().where(proposals.c.id == msg["id"]))

def handle_set_deposit(self, msg):
msg["depositor_id"] = self.get_account_id(msg["depositor"])
del msg["depositor"]
msg["tx_id"] = self.get_transaction_id(msg["tx_hash"])
del msg["tx_hash"]
self.conn.execute(insert(deposits).values(**msg).on_conflict_do_update(constraint="deposits_pkey", set_=msg))

def handle_remove_deposit(self, msg):
self.conn.execute(deposits.delete().where(deposits.c.proposal_id == msg["proposal_id"]))

def handle_set_vote_weighted(self, msg):
msg["voter_id"] = self.get_account_id(msg["voter"])
del msg["voter"]
msg["tx_id"] = self.get_transaction_id(msg["tx_hash"])
del msg["tx_hash"]
self.conn.execute(insert(votes).values(**msg).on_conflict_do_update(constraint="votes_pkey", set_=msg))

def handle_remove_votes(self, msg):
self.conn.execute(votes.delete().where(votes.c.proposal_id == msg["proposal_id"]))

def handle_update_proposal(self, msg):
condition = True
for col in proposals.primary_key.columns.values():
Expand Down
14 changes: 14 additions & 0 deletions hooks/emitter/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ func (h *Hook) handleMsgVote(
detail["title"] = proposal.Title
}

func (h *Hook) handleMsgCancelProposal(msg *v1.MsgCancelProposal) {
h.Write("REMOVE_DEPOSIT", common.JsDict{
"proposal_id": msg.ProposalId,
})

h.Write("REMOVE_VOTES", common.JsDict{
"proposal_id": msg.ProposalId,
})

h.Write("REMOVE_PROPOSAL", common.JsDict{
"id": msg.ProposalId,
})
}

// handleV1beta1MsgVote implements emitter handler for MsgVote v1beta1.
func (h *Hook) handleV1beta1MsgVote(
ctx sdk.Context, txHash []byte, msg *v1beta1.MsgVote, detail common.JsDict,
Expand Down
2 changes: 2 additions & 0 deletions hooks/emitter/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ func (h *Hook) handleMsg(ctx sdk.Context, txHash []byte, msg sdk.Msg, events []a
h.handleV1beta1MsgDeposit(ctx, txHash, msg, detail)
case *govv1.MsgDeposit:
h.handleMsgDeposit(ctx, txHash, msg, detail)
case *govv1.MsgCancelProposal:
h.handleMsgCancelProposal(msg)
case *channeltypes.MsgRecvPacket:
h.handleMsgRecvPacket(ctx, txHash, msg, events, evMap, detail)
case *transfertypes.MsgTransfer:
Expand Down

0 comments on commit b56eb71

Please sign in to comment.