4
4
"fmt"
5
5
"time"
6
6
7
+ tmbytes "github.com/cometbft/cometbft/libs/bytes"
7
8
sdk "github.com/cosmos/cosmos-sdk/types"
8
9
9
10
"github.com/bandprotocol/chain/v2/pkg/tss"
@@ -57,23 +58,24 @@ func (k Keeper) CreateGroupReplacement(
57
58
return 0 , err
58
59
}
59
60
60
- k . SetReplacement ( ctx , types.Replacement {
61
+ replacement = types.Replacement {
61
62
SigningID : signing .ID ,
62
63
CurrentGroupID : currentGroupID ,
63
64
CurrentPubKey : currentGroup .PubKey ,
64
65
NewGroupID : newGroupID ,
65
66
NewPubKey : newGroup .PubKey ,
66
67
Status : types .REPLACEMENT_STATUS_WAITING_SIGN ,
67
68
ExecTime : execTime ,
68
- })
69
+ }
70
+ k .SetReplacement (ctx , replacement )
69
71
70
72
ctx .EventManager ().EmitEvent (
71
73
sdk .NewEvent (
72
74
types .EventTypeReplacement ,
73
- sdk .NewAttribute (tsstypes .AttributeKeySigningID , fmt .Sprintf ("%d" , signing . ID )),
74
- sdk .NewAttribute (types .AttributeKeyCurrentGroupID , fmt .Sprintf ("%d" , currentGroupID )),
75
- sdk .NewAttribute (types .AttributeKeyReplacingGroupID , fmt .Sprintf ("%d" , newGroupID )),
76
- sdk .NewAttribute (types .AttributeKeyReplacementStatus , types . REPLACEMENT_STATUS_WAITING_SIGN .String ()),
75
+ sdk .NewAttribute (tsstypes .AttributeKeySigningID , fmt .Sprintf ("%d" , replacement . SigningID )),
76
+ sdk .NewAttribute (types .AttributeKeyCurrentGroupID , fmt .Sprintf ("%d" , replacement . CurrentGroupID )),
77
+ sdk .NewAttribute (types .AttributeKeyReplacingGroupID , fmt .Sprintf ("%d" , replacement . NewGroupID )),
78
+ sdk .NewAttribute (types .AttributeKeyReplacementStatus , replacement . Status .String ()),
77
79
sdk .NewAttribute (types .AttributeKeyExecTime , replacement .ExecTime .Format (time .RFC3339 )),
78
80
),
79
81
)
@@ -102,14 +104,29 @@ func (k Keeper) HandleReplaceGroup(ctx sdk.Context, endBlockTime time.Time) erro
102
104
if signing .Status == tsstypes .SIGNING_STATUS_SUCCESS {
103
105
replacement .Status = types .REPLACEMENT_STATUS_WAITING_REPLACE
104
106
k .SetReplacement (ctx , replacement )
107
+
108
+ newGroup , err := k .tssKeeper .GetGroup (ctx , replacement .NewGroupID )
109
+ if err != nil {
110
+ return err
111
+ }
112
+
113
+ rAddress , err := signing .Signature .R ().Address ()
114
+ if err != nil {
115
+ return err
116
+ }
117
+ sig := tmbytes .HexBytes (signing .Signature .S ())
118
+
105
119
ctx .EventManager ().EmitEvent (
106
120
sdk .NewEvent (
107
121
types .EventTypeReplacement ,
108
122
sdk .NewAttribute (tsstypes .AttributeKeySigningID , fmt .Sprintf ("%d" , replacement .SigningID )),
109
123
sdk .NewAttribute (types .AttributeKeyCurrentGroupID , fmt .Sprintf ("%d" , replacement .CurrentGroupID )),
110
124
sdk .NewAttribute (types .AttributeKeyReplacingGroupID , fmt .Sprintf ("%d" , replacement .NewGroupID )),
111
- sdk .NewAttribute (types .AttributeKeyReplacementStatus , types . REPLACEMENT_STATUS_WAITING_REPLACE .String ()),
125
+ sdk .NewAttribute (types .AttributeKeyReplacementStatus , replacement . Status .String ()),
112
126
sdk .NewAttribute (types .AttributeKeyExecTime , replacement .ExecTime .Format (time .RFC3339 )),
127
+ sdk .NewAttribute (types .AttributeKeyNewGroupPubKey , newGroup .PubKey .String ()),
128
+ sdk .NewAttribute (types .AttributeKeyRAddress , tmbytes .HexBytes (rAddress ).String ()),
129
+ sdk .NewAttribute (types .AttributeKeySignature , sig .String ()),
113
130
),
114
131
)
115
132
}
@@ -133,7 +150,7 @@ func (k Keeper) HandleFailReplacementSigning(ctx sdk.Context, replacement types.
133
150
sdk .NewAttribute (tsstypes .AttributeKeySigningID , fmt .Sprintf ("%d" , replacement .SigningID )),
134
151
sdk .NewAttribute (types .AttributeKeyCurrentGroupID , fmt .Sprintf ("%d" , replacement .CurrentGroupID )),
135
152
sdk .NewAttribute (types .AttributeKeyReplacingGroupID , fmt .Sprintf ("%d" , replacement .NewGroupID )),
136
- sdk .NewAttribute (types .AttributeKeyReplacementStatus , types . REPLACEMENT_STATUS_FALLEN .String ()),
153
+ sdk .NewAttribute (types .AttributeKeyReplacementStatus , replacement . Status .String ()),
137
154
sdk .NewAttribute (types .AttributeKeyExecTime , replacement .ExecTime .Format (time .RFC3339 )),
138
155
),
139
156
)
@@ -170,7 +187,7 @@ func (k Keeper) ReplaceGroup(ctx sdk.Context, replacement types.Replacement) err
170
187
sdk .NewEvent (
171
188
types .EventTypeNewGroupActivate ,
172
189
sdk .NewAttribute (types .AttributeKeyGroupID , fmt .Sprintf ("%d" , newGroup .ID )),
173
- sdk .NewAttribute (types .AttributeKeyGroupPubKey , fmt . Sprintf ( "%v" , newGroup .PubKey .String () )),
190
+ sdk .NewAttribute (types .AttributeKeyGroupPubKey , newGroup .PubKey .String ()),
174
191
),
175
192
)
176
193
0 commit comments