Skip to content

Commit b85cac1

Browse files
committed
refactor(signals): remove waku from signals and remove unused signals
1 parent 529680e commit b85cac1

File tree

11 files changed

+77
-146
lines changed

11 files changed

+77
-146
lines changed

protocol/wakusync/profile_response.go renamed to protocol/backupsync/profile_response.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wakusync
1+
package backupsync
22

33
import (
44
"github.com/status-im/status-go/images"
@@ -13,18 +13,18 @@ type BackedUpProfile struct {
1313
ProfileShowcasePreferences identity.ProfileShowcasePreferences `json:"profile_showcase_preferences,omitempty"`
1414
}
1515

16-
func (sfwr *WakuBackedUpDataResponse) SetDisplayName(displayName string) {
16+
func (sfwr *BackedUpDataResponse) SetDisplayName(displayName string) {
1717
sfwr.Profile.DisplayName = displayName
1818
}
1919

20-
func (sfwr *WakuBackedUpDataResponse) SetImages(images []images.IdentityImage) {
20+
func (sfwr *BackedUpDataResponse) SetImages(images []images.IdentityImage) {
2121
sfwr.Profile.Images = images
2222
}
2323

24-
func (sfwr *WakuBackedUpDataResponse) SetEnsUsernameDetails(ensUsernameDetails []*ens.UsernameDetail) {
24+
func (sfwr *BackedUpDataResponse) SetEnsUsernameDetails(ensUsernameDetails []*ens.UsernameDetail) {
2525
sfwr.Profile.EnsUsernameDetails = ensUsernameDetails
2626
}
2727

28-
func (sfwr *WakuBackedUpDataResponse) SetProfileShowcasePreferences(profileShowcasePreferences *identity.ProfileShowcasePreferences) {
28+
func (sfwr *BackedUpDataResponse) SetProfileShowcasePreferences(profileShowcasePreferences *identity.ProfileShowcasePreferences) {
2929
sfwr.Profile.ProfileShowcasePreferences = *profileShowcasePreferences
3030
}

protocol/backupsync/response.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package backupsync
2+
3+
import (
4+
"encoding/json"
5+
6+
accsmanagementtypes "github.com/status-im/status-go/accounts-management/types"
7+
"github.com/status-im/status-go/multiaccounts/settings"
8+
)
9+
10+
type BackedUpDataResponse struct {
11+
Clock uint64
12+
Profile *BackedUpProfile
13+
Setting *settings.SyncSettingField
14+
Keypair *accsmanagementtypes.Keypair
15+
WatchOnlyAccount *accsmanagementtypes.Account
16+
}
17+
18+
func (sfwr *BackedUpDataResponse) MarshalJSON() ([]byte, error) {
19+
responseItem := struct {
20+
Clock uint64 `json:"clock,omitempty"`
21+
Profile *BackedUpProfile `json:"backedUpProfile,omitempty"`
22+
Setting *settings.SyncSettingField `json:"backedUpSettings,omitempty"`
23+
Keypair *accsmanagementtypes.Keypair `json:"backedUpKeypair,omitempty"`
24+
WatchOnlyAccount *accsmanagementtypes.Account `json:"backedUpWatchOnlyAccount,omitempty"`
25+
}{
26+
Clock: sfwr.Clock,
27+
Profile: sfwr.Profile,
28+
Setting: sfwr.Setting,
29+
Keypair: sfwr.Keypair,
30+
WatchOnlyAccount: sfwr.WatchOnlyAccount,
31+
}
32+
33+
return json.Marshal(responseItem)
34+
}

protocol/messenger_backup_handler.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
messagingtypes "github.com/status-im/status-go/messaging/types"
1313
"github.com/status-im/status-go/multiaccounts/errors"
1414
"github.com/status-im/status-go/multiaccounts/settings"
15+
"github.com/status-im/status-go/protocol/backupsync"
1516
"github.com/status-im/status-go/protocol/communities"
1617
"github.com/status-im/status-go/protocol/protobuf"
17-
"github.com/status-im/status-go/protocol/wakusync"
1818
ensservice "github.com/status-im/status-go/services/ens"
1919
"github.com/status-im/status-go/signal"
2020
)
@@ -70,8 +70,8 @@ func (m *Messenger) handleBackedUpProfile(message *protobuf.BackedUpProfile, bac
7070
return nil
7171
}
7272

73-
response := wakusync.WakuBackedUpDataResponse{
74-
Profile: &wakusync.BackedUpProfile{},
73+
response := backupsync.BackedUpDataResponse{
74+
Profile: &backupsync.BackedUpProfile{},
7575
}
7676

7777
err := utils.ValidateDisplayName(&message.DisplayName)
@@ -168,7 +168,7 @@ func (m *Messenger) handleBackedUpProfile(message *protobuf.BackedUpProfile, bac
168168
response.SetEnsUsernameDetails(ensUsernameDetails)
169169

170170
if m.config.messengerSignalsHandler != nil {
171-
m.config.messengerSignalsHandler.SendWakuBackedUpProfile(&response)
171+
m.config.messengerSignalsHandler.SendBackedUpProfile(&response)
172172
}
173173

174174
return err
@@ -205,10 +205,10 @@ func (m *Messenger) handleLocalBackupCommunities(state *ReceivedMessageState, co
205205

206206
func (m *Messenger) PublishSettingEvent(settingField *settings.SyncSettingField) {
207207
if m.config.messengerSignalsHandler != nil {
208-
response := wakusync.WakuBackedUpDataResponse{
208+
response := backupsync.BackedUpDataResponse{
209209
Setting: settingField,
210210
}
211-
m.config.messengerSignalsHandler.SendWakuBackedUpSettings(&response)
211+
m.config.messengerSignalsHandler.SendBackedUpSettings(&response)
212212
}
213213
}
214214

protocol/messenger_config.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414

1515
"github.com/status-im/status-go/multiaccounts"
1616
"github.com/status-im/status-go/params"
17+
"github.com/status-im/status-go/protocol/backupsync"
1718
"github.com/status-im/status-go/protocol/common"
1819
"github.com/status-im/status-go/protocol/communities"
1920
"github.com/status-im/status-go/protocol/discord"
2021
"github.com/status-im/status-go/protocol/ens"
2122
"github.com/status-im/status-go/protocol/protobuf"
2223
"github.com/status-im/status-go/protocol/pushnotificationclient"
23-
"github.com/status-im/status-go/protocol/wakusync"
2424
"github.com/status-im/status-go/services/mailservers"
2525
"github.com/status-im/status-go/services/wallet"
2626
)
@@ -54,10 +54,8 @@ type MessengerSignalsHandler interface {
5454
DiscordChannelImportProgress(importProgress *discord.ImportProgress)
5555
DiscordChannelImportFinished(communityID string, channelID string)
5656
DiscordChannelImportCancelled(channelID string)
57-
SendWakuBackedUpProfile(response *wakusync.WakuBackedUpDataResponse)
58-
SendWakuBackedUpSettings(response *wakusync.WakuBackedUpDataResponse)
59-
SendWakuBackedUpKeypair(response *wakusync.WakuBackedUpDataResponse)
60-
SendWakuBackedUpWatchOnlyAccount(response *wakusync.WakuBackedUpDataResponse)
57+
SendBackedUpProfile(response *backupsync.BackedUpDataResponse)
58+
SendBackedUpSettings(response *backupsync.BackedUpDataResponse)
6159
SendCuratedCommunitiesUpdate(response *communities.KnownCommunitiesResponse)
6260
}
6361

protocol/messenger_testing_utils.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

1212
gocommon "github.com/status-im/status-go/common"
13-
"github.com/status-im/status-go/protocol/wakusync"
13+
"github.com/status-im/status-go/protocol/backupsync"
1414

1515
"github.com/status-im/status-go/protocol/identity"
1616

@@ -54,11 +54,8 @@ type MessengerSignalsHandlerMock struct {
5454
communityFoundChan chan *communities.Community
5555
}
5656

57-
func (m *MessengerSignalsHandlerMock) SendWakuBackedUpProfile(*wakusync.WakuBackedUpDataResponse) {}
58-
func (m *MessengerSignalsHandlerMock) SendWakuBackedUpSettings(*wakusync.WakuBackedUpDataResponse) {}
59-
func (m *MessengerSignalsHandlerMock) SendWakuBackedUpKeypair(*wakusync.WakuBackedUpDataResponse) {}
60-
func (m *MessengerSignalsHandlerMock) SendWakuBackedUpWatchOnlyAccount(*wakusync.WakuBackedUpDataResponse) {
61-
}
57+
func (m *MessengerSignalsHandlerMock) SendBackedUpProfile(*backupsync.BackedUpDataResponse) {}
58+
func (m *MessengerSignalsHandlerMock) SendBackedUpSettings(*backupsync.BackedUpDataResponse) {}
6259

6360
func (m *MessengerSignalsHandlerMock) HistoryArchivesProtocolEnabled() {}
6461
func (m *MessengerSignalsHandlerMock) HistoryArchivesProtocolDisabled() {}

protocol/wakusync/progress_response.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

protocol/wakusync/response.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

services/ext/signal.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"github.com/status-im/status-go/crypto/types"
55
messagingtypes "github.com/status-im/status-go/messaging/types"
66
"github.com/status-im/status-go/protocol"
7+
"github.com/status-im/status-go/protocol/backupsync"
78
"github.com/status-im/status-go/protocol/communities"
89
"github.com/status-im/status-go/protocol/discord"
9-
"github.com/status-im/status-go/protocol/wakusync"
1010
"github.com/status-im/status-go/signal"
1111
)
1212

@@ -157,20 +157,12 @@ func (m *MessengerSignalsHandler) DiscordChannelImportCancelled(id string) {
157157
signal.SendDiscordChannelImportCancelled(id)
158158
}
159159

160-
func (m *MessengerSignalsHandler) SendWakuBackedUpProfile(response *wakusync.WakuBackedUpDataResponse) {
161-
signal.SendWakuBackedUpProfile(response)
160+
func (m *MessengerSignalsHandler) SendBackedUpProfile(response *backupsync.BackedUpDataResponse) {
161+
signal.SendBackedUpProfile(response)
162162
}
163163

164-
func (m *MessengerSignalsHandler) SendWakuBackedUpSettings(response *wakusync.WakuBackedUpDataResponse) {
165-
signal.SendWakuBackedUpSettings(response)
166-
}
167-
168-
func (m *MessengerSignalsHandler) SendWakuBackedUpKeypair(response *wakusync.WakuBackedUpDataResponse) {
169-
signal.SendWakuBackedUpKeypair(response)
170-
}
171-
172-
func (m *MessengerSignalsHandler) SendWakuBackedUpWatchOnlyAccount(response *wakusync.WakuBackedUpDataResponse) {
173-
signal.SendWakuBackedUpWatchOnlyAccount(response)
164+
func (m *MessengerSignalsHandler) SendBackedUpSettings(response *backupsync.BackedUpDataResponse) {
165+
signal.SendBackedUpSettings(response)
174166
}
175167

176168
func (m *MessengerSignalsHandler) SendCuratedCommunitiesUpdate(response *communities.KnownCommunitiesResponse) {

services/wallet/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import (
2121
"github.com/status-im/status-go/multiaccounts/accounts"
2222
"github.com/status-im/status-go/params"
2323
"github.com/status-im/status-go/pkg/pubsub"
24+
"github.com/status-im/status-go/protocol/backupsync"
2425
protocolCommon "github.com/status-im/status-go/protocol/common"
2526
"github.com/status-im/status-go/protocol/protobuf"
2627
"github.com/status-im/status-go/protocol/syncing"
27-
"github.com/status-im/status-go/protocol/wakusync"
2828
"github.com/status-im/status-go/rpc"
2929
"github.com/status-im/status-go/server"
3030
"github.com/status-im/status-go/services/ens/ensresolver"
@@ -510,7 +510,7 @@ func (s *Service) handleWatchOnlyAccount(message *protobuf.SyncAccount) error {
510510
if err != nil && !errors.Is(err, syncing.ErrTryingToStoreOldWalletAccount) {
511511
return err
512512
}
513-
response := wakusync.WakuBackedUpDataResponse{
513+
response := backupsync.BackedUpDataResponse{
514514
WatchOnlyAccount: acc,
515515
}
516516
encodedmessage, err := json.Marshal(response)

signal/events_backup_sync.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package signal
2+
3+
import "encoding/json"
4+
5+
const (
6+
// EventSyncFromWakuProfile is emitted while applying backed up profile data
7+
EventBackedUpProfile = "backedup.profile"
8+
9+
// EventBackedUpSettings is emitted while applying backed up settings
10+
EventBackedUpSettings = "backedup.settings"
11+
)
12+
13+
func SendBackedUpProfile(obj json.Marshaler) {
14+
send(EventBackedUpProfile, obj)
15+
}
16+
17+
func SendBackedUpSettings(obj json.Marshaler) {
18+
send(EventBackedUpSettings, obj)
19+
}

0 commit comments

Comments
 (0)