Skip to content

Commit

Permalink
feat(phase2): register event for rpc endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Dec 21, 2022
1 parent 340e1b0 commit 4ce3fa1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
35 changes: 33 additions & 2 deletions graphql/event.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package graphql

import "encoding/json"
import (
"encoding/json"
"net/url"
)

const GenTXSubmittedEventType = "gentx-submitted"
const (
GenTXSubmittedEventType = "gentx-submitted"
RegisterRPCEndpointEventType = "register-rpc-endpoint"
)

type GenTXSubmittedEvent struct {
Twitter *string `json:"twitter,omitempty"`
Expand Down Expand Up @@ -30,3 +36,28 @@ func Unmarshall(data map[string]interface{}) (*GenTXSubmittedEvent, error) {
err = json.Unmarshal(d, &event)
return event, err
}

type RegisterRPCEndpointEvent struct {
Validator string `json:"validator"`
url *url.URL `json:"url"`
}

func (e *RegisterRPCEndpointEvent) Marshall() (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 UnmarshallRegisterRPCEndpointEvent(data map[string]interface{}) (*RegisterRPCEndpointEvent, error) {
var event *RegisterRPCEndpointEvent
d, err := json.Marshal(data)
if err != nil {
return nil, err
}
err = json.Unmarshal(d, &event)
return event, err
}
20 changes: 19 additions & 1 deletion graphql/schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ce3fa1

Please sign in to comment.