Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore_: remove waku api wrappers #6245

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions protocol/messenger_waku_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ import (
type testWakuWrapper struct {
*bridge.GethWakuWrapper

publicWakuAPIWrapper *testPublicWakuAPIWrapper
api *testPublicWakuAPI
}

func newTestWaku(w *wakuv1.Waku) wakutypes.Waku {
wrapper := bridge.NewGethWakuWrapper(w)
return &testWakuWrapper{
GethWakuWrapper: wrapper.(*bridge.GethWakuWrapper),
publicWakuAPIWrapper: newTestPublicWakuAPI(wakuv1.NewPublicWakuAPI(w)).(*testPublicWakuAPIWrapper),
GethWakuWrapper: wrapper.(*bridge.GethWakuWrapper),
api: newTestPublicWakuAPI(wakuv1.NewPublicWakuAPI(w)),
}
}

func (tw *testWakuWrapper) PublicWakuAPI() wakutypes.PublicWakuAPI {
return tw.publicWakuAPIWrapper
return tw.api
}

func (tw *testWakuWrapper) SubscribePostEvents() chan *PostMessageSubscription {
subscription := make(chan *PostMessageSubscription, 100)
tw.publicWakuAPIWrapper.postSubscriptions = append(tw.publicWakuAPIWrapper.postSubscriptions, subscription)
tw.api.postSubscriptions = append(tw.api.postSubscriptions, subscription)
return subscription
}

Expand All @@ -39,21 +39,20 @@ type PostMessageSubscription struct {
msg *wakutypes.NewMessage
}

type testPublicWakuAPIWrapper struct {
*bridge.GethPublicWakuAPIWrapper
type testPublicWakuAPI struct {
*wakuv1.PublicWakuAPI

postSubscriptions []chan *PostMessageSubscription
}

func newTestPublicWakuAPI(api *wakuv1.PublicWakuAPI) wakutypes.PublicWakuAPI {
wrapper := bridge.NewGethPublicWakuAPIWrapper(api)
return &testPublicWakuAPIWrapper{
GethPublicWakuAPIWrapper: wrapper.(*bridge.GethPublicWakuAPIWrapper),
func newTestPublicWakuAPI(api *wakuv1.PublicWakuAPI) *testPublicWakuAPI {
return &testPublicWakuAPI{
PublicWakuAPI: api,
}
}

func (tp *testPublicWakuAPIWrapper) Post(ctx context.Context, req wakutypes.NewMessage) ([]byte, error) {
id, err := tp.GethPublicWakuAPIWrapper.Post(ctx, req)
func (tp *testPublicWakuAPI) Post(ctx context.Context, req wakutypes.NewMessage) ([]byte, error) {
id, err := tp.PublicWakuAPI.Post(ctx, req)
if err != nil {
return nil, err
}
Expand Down
64 changes: 0 additions & 64 deletions waku/bridge/public_waku_api.go

This file was deleted.

64 changes: 0 additions & 64 deletions waku/bridge/public_wakuv2_api.go

This file was deleted.

2 changes: 1 addition & 1 deletion waku/bridge/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func GetGethWakuFrom(m wakutypes.Waku) *wakuv1.Waku {
}

func (w *GethWakuWrapper) PublicWakuAPI() wakutypes.PublicWakuAPI {
return NewGethPublicWakuAPIWrapper(wakuv1.NewPublicWakuAPI(w.waku))
return wakuv1.NewPublicWakuAPI(w.waku)
}

func (w *GethWakuWrapper) Version() uint {
Expand Down
2 changes: 1 addition & 1 deletion waku/bridge/wakuv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GetGethWakuV2From(m wakutypes.Waku) *wakuv2.Waku {
}

func (w *gethWakuV2Wrapper) PublicWakuAPI() wakutypes.PublicWakuAPI {
return NewGethPublicWakuV2APIWrapper(wakuv2.NewPublicWakuAPI(w.waku))
return wakuv2.NewPublicWakuAPI(w.waku)
}

func (w *gethWakuV2Wrapper) Version() uint {
Expand Down
8 changes: 6 additions & 2 deletions wakuv1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"go.uber.org/zap"

"github.com/status-im/status-go/logutils"

ethtypes "github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/waku/types"
"github.com/status-im/status-go/wakuv1/common"

Expand Down Expand Up @@ -58,6 +60,8 @@ type PublicWakuAPI struct {
lastUsed map[string]time.Time // keeps track when a filter was polled for the last time.
}

var _ types.PublicWakuAPI = (*PublicWakuAPI)(nil)

// NewPublicWakuAPI create a new RPC waku service.
func NewPublicWakuAPI(w *Waku) *PublicWakuAPI {
api := &PublicWakuAPI{
Expand Down Expand Up @@ -122,7 +126,7 @@ func (api *PublicWakuAPI) NewKeyPair(ctx context.Context) (string, error) {
}

// AddPrivateKey imports the given private key.
func (api *PublicWakuAPI) AddPrivateKey(ctx context.Context, privateKey hexutil.Bytes) (string, error) {
func (api *PublicWakuAPI) AddPrivateKey(ctx context.Context, privateKey ethtypes.HexBytes) (string, error) {
key, err := crypto.ToECDSA(privateKey)
if err != nil {
return "", err
Expand Down Expand Up @@ -212,7 +216,7 @@ func (api *PublicWakuAPI) CancelLightClient(ctx context.Context) bool {

// Post posts a message on the Waku network.
// returns the hash of the message in case of success.
func (api *PublicWakuAPI) Post(ctx context.Context, req types.NewMessage) (hexutil.Bytes, error) {
func (api *PublicWakuAPI) Post(ctx context.Context, req types.NewMessage) ([]byte, error) {
var (
symKeyGiven = len(req.SymKeyID) > 0
pubKeyGiven = len(req.PublicKey) > 0
Expand Down
7 changes: 5 additions & 2 deletions wakuv2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/waku-org/go-waku/waku/v2/payload"
"github.com/waku-org/go-waku/waku/v2/protocol/pb"

ethtypes "github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/logutils"
"github.com/status-im/status-go/waku/types"
"github.com/status-im/status-go/wakuv2/common"
Expand Down Expand Up @@ -63,6 +64,8 @@ type PublicWakuAPI struct {
lastUsed map[string]time.Time // keeps track when a filter was polled for the last time.
}

var _ types.PublicWakuAPI = (*PublicWakuAPI)(nil)

// NewPublicWakuAPI create a new RPC waku service.
func NewPublicWakuAPI(w *Waku) *PublicWakuAPI {
api := &PublicWakuAPI{
Expand Down Expand Up @@ -95,7 +98,7 @@ func (api *PublicWakuAPI) NewKeyPair(ctx context.Context) (string, error) {
}

// AddPrivateKey imports the given private key.
func (api *PublicWakuAPI) AddPrivateKey(ctx context.Context, privateKey hexutil.Bytes) (string, error) {
func (api *PublicWakuAPI) AddPrivateKey(ctx context.Context, privateKey ethtypes.HexBytes) (string, error) {
key, err := crypto.ToECDSA(privateKey)
if err != nil {
return "", err
Expand Down Expand Up @@ -176,7 +179,7 @@ func (api *PublicWakuAPI) BloomFilter() []byte {

// Post posts a message on the Waku network.
// returns the hash of the message in case of success.
func (api *PublicWakuAPI) Post(ctx context.Context, req types.NewMessage) (hexutil.Bytes, error) {
func (api *PublicWakuAPI) Post(ctx context.Context, req types.NewMessage) ([]byte, error) {
var (
symKeyGiven = len(req.SymKeyID) > 0
pubKeyGiven = len(req.PublicKey) > 0
Expand Down
Loading