@@ -68,7 +68,7 @@ type NodeInterface interface {
6868 StartCatchup (catchpoint string ) error
6969 AbortCatchup (catchpoint string ) error
7070 Config () config.Local
71- InstallParticipationKey (partKeyBinary * []byte ) (account.ParticipationID , error )
71+ InstallParticipationKey (partKeyBinary []byte ) (account.ParticipationID , error )
7272 ListParticipationKeys () ([]account.ParticipationRecord , error )
7373 GetParticipationKey (account.ParticipationID ) (account.ParticipationRecord , error )
7474 RemoveParticipationKey (account.ParticipationID ) error
@@ -102,19 +102,19 @@ func convertParticipationRecord(record account.ParticipationRecord) generated.Pa
102102 }
103103
104104 // Optional fields.
105- participationKey .EffectiveFirstValid = roundToPtrOrNil (record .EffectiveFirst )
105+ if record .EffectiveLast != 0 && record .EffectiveFirst == 0 {
106+ // Special case for first valid on round 0
107+ zero := uint64 (0 )
108+ participationKey .EffectiveFirstValid = & zero
109+ } else {
110+ participationKey .EffectiveFirstValid = roundToPtrOrNil (record .EffectiveFirst )
111+ }
106112 participationKey .EffectiveLastValid = roundToPtrOrNil (record .EffectiveLast )
107113 participationKey .LastVote = roundToPtrOrNil (record .LastVote )
108114 participationKey .LastBlockProposal = roundToPtrOrNil (record .LastBlockProposal )
109115 participationKey .LastVote = roundToPtrOrNil (record .LastVote )
110116 participationKey .LastStateProof = roundToPtrOrNil (record .LastStateProof )
111117
112- // Special case for first valid on round 0
113- if record .EffectiveLast != 0 && record .EffectiveFirst == 0 {
114- zero := uint64 (0 )
115- participationKey .EffectiveFirstValid = & zero
116- }
117-
118118 return participationKey
119119}
120120
@@ -152,7 +152,7 @@ func (v2 *Handlers) AddParticipationKey(ctx echo.Context) error {
152152 return badRequest (ctx , err , err .Error (), v2 .Log )
153153 }
154154
155- partID , err := v2 .Node .InstallParticipationKey (& partKeyBinary )
155+ partID , err := v2 .Node .InstallParticipationKey (partKeyBinary )
156156
157157 if err != nil {
158158 return badRequest (ctx , err , err .Error (), v2 .Log )
@@ -167,7 +167,7 @@ func (v2 *Handlers) AddParticipationKey(ctx echo.Context) error {
167167// (DELETE /v2/participation/{participation-id})
168168func (v2 * Handlers ) DeleteParticipationKeyByID (ctx echo.Context , participationID string ) error {
169169
170- decodedParticipationID , err := account .ParticipationIDFromString (participationID )
170+ decodedParticipationID , err := account .ParseParticipationID (participationID )
171171
172172 if err != nil {
173173 return badRequest (ctx , err , err .Error (), v2 .Log )
@@ -176,12 +176,11 @@ func (v2 *Handlers) DeleteParticipationKeyByID(ctx echo.Context, participationID
176176 err = v2 .Node .RemoveParticipationKey (decodedParticipationID )
177177
178178 if err != nil {
179-
180179 if errors .Is (err , account .ErrParticipationIDNotFound ) {
181- return ctx . JSON ( http . StatusOK , generated. ErrorResponse { Message : "participation id not found" } )
180+ return notFound ( ctx , account . ErrParticipationIDNotFound , "participation id not found" , v2 . Log )
182181 }
183182
184- return badRequest (ctx , err , err .Error (), v2 .Log )
183+ return internalError (ctx , err , err .Error (), v2 .Log )
185184 }
186185
187186 return ctx .NoContent (http .StatusOK )
@@ -191,7 +190,7 @@ func (v2 *Handlers) DeleteParticipationKeyByID(ctx echo.Context, participationID
191190// (GET /v2/participation/{participation-id})
192191func (v2 * Handlers ) GetParticipationKeyByID (ctx echo.Context , participationID string ) error {
193192
194- decodedParticipationID , err := account .ParticipationIDFromString (participationID )
193+ decodedParticipationID , err := account .ParseParticipationID (participationID )
195194
196195 if err != nil {
197196 return badRequest (ctx , err , err .Error (), v2 .Log )
@@ -200,7 +199,11 @@ func (v2 *Handlers) GetParticipationKeyByID(ctx echo.Context, participationID st
200199 participationRecord , err := v2 .Node .GetParticipationKey (decodedParticipationID )
201200
202201 if err != nil {
203- return badRequest (ctx , err , err .Error (), v2 .Log )
202+ return internalError (ctx , err , err .Error (), v2 .Log )
203+ }
204+
205+ if participationRecord .IsZero () {
206+ return notFound (ctx , account .ErrParticipationIDNotFound , account .ErrParticipationIDNotFound .Error (), v2 .Log )
204207 }
205208
206209 response := convertParticipationRecord (participationRecord )
0 commit comments