Skip to content

Commit

Permalink
Merge pull request #521 from bandprotocol/extra/rest-fix-tss-member
Browse files Browse the repository at this point in the history
[Extra/rest] fix tss member
  • Loading branch information
RogerKSI authored Dec 12, 2024
2 parents 763a900 + b199d29 commit 4c0651e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hooks/emitter/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func (h *Hook) handleMsgEvent(ctx sdk.Context, txHash []byte, event abci.Event)
h.handleTunnelEventTypeActivateTunnel(ctx, evMap)
case tunneltypes.EventTypeDeactivateTunnel:
h.handleTunnelEventTypeDeactivateTunnel(ctx, evMap)
case tsstypes.EventTypeSetMemberIsActive:
h.handleTSSSetMember(ctx, evMap)
}
}

Expand Down Expand Up @@ -237,6 +239,8 @@ func (h *Hook) handleBeginBlockEndBlockEvent(
for _, gid := range groupIDs {
h.handleTSSSetGroup(ctx, tss.GroupID(common.Atoi(gid)))
}
case tsstypes.EventTypeSetMemberIsActive:
h.handleTSSSetMember(ctx, evMap)
case tunneltypes.EventTypeProducePacketSuccess:
h.handleTunnelEventTypeProducePacketSuccess(ctx, evMap)
case tunneltypes.EventTypeActivateTunnel:
Expand Down
13 changes: 13 additions & 0 deletions hooks/emitter/tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package emitter

import (
"encoding/hex"
"fmt"

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

Expand Down Expand Up @@ -210,6 +211,18 @@ func (h *Hook) handleTSSSetGroup(ctx sdk.Context, gid tss.GroupID) {
}
}

func (h *Hook) handleTSSSetMember(ctx sdk.Context, evMap common.EvMap) {
groupID := tss.GroupID(common.Atoui(evMap[types.EventTypeSetMemberIsActive+"."+types.AttributeKeyGroupID][0]))
memberID := tss.MemberID(common.Atoui(evMap[types.EventTypeSetMemberIsActive+"."+types.AttributeKeyMemberID][0]))

member, err := h.tssKeeper.GetMember(ctx, groupID, memberID)
if err != nil {
panic(fmt.Sprintf("invalid member; groupID: %d, memberID: %d", groupID, memberID))
}

h.emitSetTSSMember(member)
}

// handleTSSEventSubmitSignature implements emitter handler for SubmitSignature event.
func (h *Hook) handleTSSEventSubmitSignature(ctx sdk.Context, evMap common.EvMap) {
sids := evMap[types.EventTypeSubmitSignature+"."+types.AttributeKeySigningID]
Expand Down

0 comments on commit 4c0651e

Please sign in to comment.