Skip to content

Commit

Permalink
Merge branch 'master' into rest/validate-lp-request
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos authored Apr 8, 2024
2 parents c868b31 + e29cf0d commit 9a5f658
Show file tree
Hide file tree
Showing 21 changed files with 546 additions and 2,250 deletions.
3 changes: 3 additions & 0 deletions cmd/waku/server/rest/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type RestWakuMessage struct {
Version *uint32 `json:"version,omitempty"`
Timestamp *int64 `json:"timestamp,omitempty"`
Meta []byte `json:"meta,omitempty"`
Ephemeral *bool `json:"ephemeral"`
}

func (r *RestWakuMessage) FromProto(input *pb.WakuMessage) error {
Expand All @@ -25,6 +26,7 @@ func (r *RestWakuMessage) FromProto(input *pb.WakuMessage) error {
r.Timestamp = input.Timestamp
r.Version = input.Version
r.Meta = input.Meta
r.Ephemeral = input.Ephemeral

return nil
}
Expand All @@ -40,6 +42,7 @@ func (r *RestWakuMessage) ToProto() (*pb.WakuMessage, error) {
Version: r.Version,
Timestamp: r.Timestamp,
Meta: r.Meta,
Ephemeral: r.Ephemeral,
}

return msg, nil
Expand Down
4 changes: 3 additions & 1 deletion cmd/waku/server/rest/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ func TestRelayGetV1Messages(t *testing.T) {

// Wait for the subscription to be started
time.Sleep(1 * time.Second)

ephemeral := true
msg := &RestWakuMessage{
Payload: []byte{1, 2, 3},
ContentTopic: "test",
Timestamp: utils.GetUnixEpoch(),
Ephemeral: &ephemeral,
}
msgJsonBytes, err := json.Marshal(msg)
require.NoError(t, err)
Expand All @@ -152,6 +153,7 @@ func TestRelayGetV1Messages(t *testing.T) {
err = json.Unmarshal(rr.Body.Bytes(), &messages)
require.NoError(t, err)
require.Len(t, messages, 1)
require.Equal(t, *messages[0].Ephemeral, true)

rr = httptest.NewRecorder()
req, _ = http.NewRequest(http.MethodGet, "/relay/v1/messages/test", bytes.NewReader([]byte{}))
Expand Down
8 changes: 7 additions & 1 deletion cmd/waku/server/rest/waku_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ func NewWakuRest(node *node.WakuNode, config RestConfig, log *zap.Logger) *WakuR
mux := chi.NewRouter()
mux.Use(middleware.Logger)
mux.Use(middleware.NoCache)

mux.Use(func(h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
h.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
})
if config.EnablePProf {
mux.Mount("/debug", middleware.Profiler())
}
Expand Down
15 changes: 7 additions & 8 deletions examples/basic-relay/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ replace github.com/waku-org/go-waku => ../..
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/status-im/go-ethereum v1.10.25-status.4

require (
github.com/ethereum/go-ethereum v1.10.26
github.com/ethereum/go-ethereum v1.11.6
github.com/multiformats/go-multiaddr v0.12.0
github.com/urfave/cli/v2 v2.24.4
github.com/waku-org/go-waku v0.2.3-0.20221109195301-b2a5a68d28ba
go.uber.org/zap v1.26.0
Expand All @@ -23,33 +24,34 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d // indirect
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cruxic/go-hmac-drbg v0.0.0-20170206035330-84c46983886d // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
Expand Down Expand Up @@ -81,7 +83,6 @@ require (
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multiaddr v0.12.0 // indirect
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
Expand All @@ -102,15 +103,13 @@ require (
github.com/quic-go/quic-go v0.39.4 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rjeczalik/notify v0.9.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/status-im/status-go/extkeys v1.1.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
github.com/waku-org/go-discover v0.0.0-20240321122731-fe708039d53f // indirect
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20240110193335-a67d1cc760a0 // indirect
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b // indirect
Expand Down
Loading

0 comments on commit 9a5f658

Please sign in to comment.