Skip to content

Commit

Permalink
fix event attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
nkitlabs committed Nov 27, 2024
1 parent 16b66b7 commit 0d96cb9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 46 deletions.
4 changes: 2 additions & 2 deletions hooks/emitter/tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ func (h *Hook) handleInitTssModule(ctx sdk.Context) {
func (h *Hook) handleTssEventCreateSigning(ctx sdk.Context, evMap common.EvMap) {
sids := evMap[types.EventTypeCreateSigning+"."+types.AttributeKeySigningID]
contentTypes := evMap[types.EventTypeCreateSigning+"."+types.AttributeKeyContentType]
contentInfos := evMap[types.EventTypeCreateSigning+"."+types.AttributeKeyContentInfo]
contentInfos := evMap[types.EventTypeCreateSigning+"."+types.AttributeKeyContent]
originatorTypes := evMap[types.EventTypeCreateSigning+"."+types.AttributeKeyOriginatorType]
originatorInfos := evMap[types.EventTypeCreateSigning+"."+types.AttributeKeyOriginatorInfo]
originatorInfos := evMap[types.EventTypeCreateSigning+"."+types.AttributeKeyOriginator]

for i, sid := range sids {
id := tss.SigningID(common.Atoi(sid))
Expand Down
11 changes: 6 additions & 5 deletions x/tss/keeper/keeper_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ func (k Keeper) RequestSigning(
return 0, err
}

contentType := fmt.Sprintf("%s/%s", content.OrderRoute(), content.OrderType())
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeCreateSigning,
sdk.NewAttribute(types.AttributeKeySigningID, fmt.Sprintf("%d", signingID)),
sdk.NewAttribute(types.AttributeKeyGroupID, fmt.Sprintf("%d", groupID)),
sdk.NewAttribute(types.AttributeKeyContentType, contentType),
sdk.NewAttribute(types.AttributeKeyContentInfo, content.String()),
sdk.NewAttribute(types.AttributeKeyOriginatorType, originator.Type()),
sdk.NewAttribute(types.AttributeKeyOriginatorInfo, originator.String()),
sdk.NewAttribute(types.AttributeKeyContentType, sdk.MsgTypeURL(content)),
sdk.NewAttribute(types.AttributeKeyContent, content.String()),
sdk.NewAttribute(types.AttributeKeyOriginatorType, sdk.MsgTypeURL(originator)),
sdk.NewAttribute(types.AttributeKeyOriginator, originator.String()),
sdk.NewAttribute(types.AttributeKeyEncodedOriginator, hex.EncodeToString(originatorBz)),
sdk.NewAttribute(types.AttributeKeyMessage, hex.EncodeToString(contentMsg)),
))

// initiate new signing round
Expand Down
11 changes: 11 additions & 0 deletions x/tss/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgSubmitSignature{}, "tss/MsgSubmitSignature")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "tss/MsgUpdateParams")

cdc.RegisterInterface((*Originator)(nil), nil)
cdc.RegisterInterface((*Content)(nil), nil)

cdc.RegisterConcrete(&DirectOriginator{}, "tss/DirectOriginator", nil)
cdc.RegisterConcrete(&TunnelOriginator{}, "tss/TunnelOriginator", nil)
cdc.RegisterConcrete(&TextSignatureOrder{}, "tss/TextSignatureOrder", nil)
cdc.RegisterConcrete(Params{}, "tss/Params", nil)
}
Expand All @@ -36,6 +41,12 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
&MsgUpdateParams{},
)

registry.RegisterInterface(
"tss.v1beta1.Originator",
(*Originator)(nil),
&DirectOriginator{}, &TunnelOriginator{},
)

registry.RegisterInterface(
"tss.v1beta1.Content",
(*Content)(nil),
Expand Down
59 changes: 30 additions & 29 deletions x/tss/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,34 @@ const (
EventTypeSigningFailed = "signing_failed"
EventTypeSubmitSignature = "submit_signature"

AttributeKeyGroupID = "group_id"
AttributeKeyMemberID = "member_id"
AttributeKeyAddress = "address"
AttributeKeySize = "size"
AttributeKeyThreshold = "threshold"
AttributeKeyPubKey = "pub_key"
AttributeKeyStatus = "status"
AttributeKeyDKGContext = "dkg_context"
AttributeKeyModuleOwner = "module_owner"
AttributeKeyRound1Info = "round1_info"
AttributeKeyRound2Info = "round2_info"
AttributeKeyComplainantID = "complainant_id"
AttributeKeyRespondentID = "respondent_id"
AttributeKeyKeySym = "key_sym"
AttributeKeySignature = "signature"
AttributeKeyOwnPubKeySig = "own_pub_key_sig"
AttributeKeySigningID = "signing_id"
AttributeKeyReason = "reason"
AttributeKeyMessage = "message"
AttributeKeyGroupPubNonce = "group_pub_nonce"
AttributeKeyAttempt = "attempt"
AttributeKeyPubNonce = "pub_nonce"
AttributeKeyBindingFactor = "binding_factor"
AttributeKeyPubD = "pub_d"
AttributeKeyPubE = "pub_e"
AttributeKeyContentInfo = "content_info"
AttributeKeyContentType = "content_type"
AttributeKeyOriginatorInfo = "originator_info"
AttributeKeyOriginatorType = "originator_type"
AttributeKeyGroupID = "group_id"
AttributeKeyMemberID = "member_id"
AttributeKeyAddress = "address"
AttributeKeySize = "size"
AttributeKeyThreshold = "threshold"
AttributeKeyPubKey = "pub_key"
AttributeKeyStatus = "status"
AttributeKeyDKGContext = "dkg_context"
AttributeKeyModuleOwner = "module_owner"
AttributeKeyRound1Info = "round1_info"
AttributeKeyRound2Info = "round2_info"
AttributeKeyComplainantID = "complainant_id"
AttributeKeyRespondentID = "respondent_id"
AttributeKeyKeySym = "key_sym"
AttributeKeySignature = "signature"
AttributeKeyOwnPubKeySig = "own_pub_key_sig"
AttributeKeySigningID = "signing_id"
AttributeKeyReason = "reason"
AttributeKeyMessage = "message"
AttributeKeyGroupPubNonce = "group_pub_nonce"
AttributeKeyAttempt = "attempt"
AttributeKeyPubNonce = "pub_nonce"
AttributeKeyBindingFactor = "binding_factor"
AttributeKeyPubD = "pub_d"
AttributeKeyPubE = "pub_e"
AttributeKeyContent = "content"
AttributeKeyContentType = "content_type"
AttributeKeyOriginator = "originator"
AttributeKeyOriginatorType = "originator_type"
AttributeKeyEncodedOriginator = "encoded_originator"
)
10 changes: 0 additions & 10 deletions x/tss/types/originator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type Originator interface {

Encode() ([]byte, error)
Validate(p Params) error
Type() string
}

// ====================================
Expand Down Expand Up @@ -72,11 +71,6 @@ func (o DirectOriginator) Encode() ([]byte, error) {
return bz, nil
}

// Type returns the type of the originator.
func (o DirectOriginator) Type() string {
return "DirectOriginator"
}

// ====================================
// TunnelOriginator
// ====================================
Expand Down Expand Up @@ -129,7 +123,3 @@ func (o TunnelOriginator) Encode() ([]byte, error) {

return bz, nil
}

func (o TunnelOriginator) Type() string {
return "TunnelOriginator"
}

0 comments on commit 0d96cb9

Please sign in to comment.