Skip to content

Commit

Permalink
feat(event): design validator updated event
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Dec 22, 2022
1 parent eb08434 commit a10a34c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions graphql/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
const (
GenTXSubmittedEventType = "gentx-submitted"
ValidatorRegisteredEventType = "validator-registered"
ValidatorUpdatedEventType = "validator-updated"
RegisterRPCEndpointEventType = "register-rpc-endpoint"
)

Expand Down Expand Up @@ -69,6 +70,35 @@ func (e *ValidatorRegisteredEvent) Unmarshal(data map[string]interface{}) error
return json.Unmarshal(d, e)
}

type ValidatorUpdatedEvent struct {
Delegator types.AccAddress `json:"delegator"`
Twitter *string `json:"twitter,omitempty"`
Discord string `json:"discord"`
Country string `json:"country"`
Valoper types.ValAddress `json:"valoper"`
Valcons types.ConsAddress `json:"valcons"`
Description stakingtypes.Description `json:"description"`
}

func (e *ValidatorUpdatedEvent) Marshal() (map[string]interface{}, error) {
var event map[string]interface{}
data, err := json.Marshal(&e)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &event)
return event, err
}

func (e *ValidatorUpdatedEvent) Unmarshal(data map[string]interface{}) error {
d, err := json.Marshal(data)
if err != nil {
return err
}

return json.Unmarshal(d, e)
}

type RegisterRPCEndpointEvent struct {
Validator types.ValAddress `json:"validator"`
URL *url.URL `json:"url"`
Expand Down

0 comments on commit a10a34c

Please sign in to comment.