Skip to content

Commit b06f642

Browse files
committed
emit event for btc bridge dkg
1 parent 08ccb9c commit b06f642

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

x/btcbridge/keeper/msg_server.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"encoding/hex"
77
"fmt"
8+
"strings"
89

910
"github.com/btcsuite/btcd/btcutil/psbt"
1011

@@ -295,9 +296,15 @@ func (m msgServer) InitiateDKG(goCtx context.Context, msg *types.MsgInitiateDKG)
295296
}
296297

297298
// Emit events
298-
m.EmitEvent(ctx, msg.Authority,
299-
sdk.NewAttribute("id", fmt.Sprintf("%d", req.Id)),
300-
sdk.NewAttribute("expiration", req.Expiration.String()),
299+
ctx.EventManager().EmitEvent(
300+
sdk.NewEvent(
301+
types.EventTypeInitiateDKG,
302+
sdk.NewAttribute(types.AttributeKeyId, fmt.Sprintf("%d", req.Id)),
303+
sdk.NewAttribute(types.AttributeKeyParticipants, strings.Join(types.GetParticipantPubKeys(req.Participants), types.AttributeValueSeparator)),
304+
sdk.NewAttribute(types.AttributeKeyThreshold, fmt.Sprintf("%d", req.Threshold)),
305+
sdk.NewAttribute(types.AttributeKeyBatchSize, fmt.Sprintf("%d", len(req.VaultTypes))),
306+
sdk.NewAttribute(types.AttributeKeyExpirationTime, req.Expiration.String()),
307+
),
301308
)
302309

303310
return &types.MsgInitiateDKGResponse{}, nil

x/btcbridge/types/events.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ package types
22

33
// BtcBridge module event types and attribute keys
44
const (
5+
EventTypeInitiateDKG = "initiate_dkg"
56
EventTypeInitiateSigning = "initiate_signing"
67

7-
AttributeKeyId = "id"
8+
AttributeKeyId = "id"
9+
10+
AttributeKeyParticipants = "participants"
11+
AttributeKeyThreshold = "threshold"
12+
AttributeKeyBatchSize = "batch_size"
13+
AttributeKeyExpirationTime = "expiration_time"
14+
815
AttributeKeySigners = "signers"
916
AttributeKeySigHashes = "sig_hashes"
1017
)

x/btcbridge/types/tss.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ func ParticipantExists(participants []*DKGParticipant, consAddress string) bool
3333
return false
3434
}
3535

36+
// GetParticipantPubKeys gets consensus pub keys of all participants
37+
func GetParticipantPubKeys(participants []*DKGParticipant) []string {
38+
pubKeys := []string{}
39+
40+
for _, p := range participants {
41+
pubKeys = append(pubKeys, p.ConsensusPubkey)
42+
}
43+
44+
return pubKeys
45+
}
46+
3647
// CheckDKGCompletionRequests checks if the vaults of all the DKG completion requests are same
3748
func CheckDKGCompletionRequests(requests []*DKGCompletionRequest) bool {
3849
if len(requests) == 0 {

0 commit comments

Comments
 (0)