Skip to content

Commit 30bbd40

Browse files
feat: Disable auto refresh tokens when privacy mode is on
1 parent b3af095 commit 30bbd40

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

services/wallet/token/token-lists/token_lists.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ func NewTokenLists(appDb *sql.DB, walletDb *sql.DB) (*TokenLists, error) {
7373
// The auto-refresh interval is used to fetch the list of token lists from the remote source and update the local cache.
7474
// The auto-refresh check interval is used to check if the auto-refresh should be triggered.
7575
func (t *TokenLists) Start(ctx context.Context, remoteListUrl string, autoRefreshInterval time.Duration,
76-
autoRefreshCheckInterval time.Duration) {
76+
autoRefreshCheckInterval time.Duration, thirdpartyServicesEnabled bool) {
7777
err := t.initializeTokensLists()
7878
if err != nil {
7979
logutils.ZapLogger().Error("Failed to initialize token lists", zap.Error(err))
8080
}
8181

82+
if !thirdpartyServicesEnabled {
83+
return
84+
}
85+
8286
t.tokenListsFetcher.SetURLOfRemoteListOfTokenLists(remoteListUrl)
8387

8488
go func() {

services/wallet/token/token.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
cryptotypes "github.com/status-im/status-go/crypto/types"
2525
"github.com/status-im/status-go/logutils"
2626
"github.com/status-im/status-go/multiaccounts/accounts"
27+
"github.com/status-im/status-go/multiaccounts/settings"
2728
"github.com/status-im/status-go/params"
2829
"github.com/status-im/status-go/pkg/pubsub"
2930
"github.com/status-im/status-go/protocol/communities/token"
@@ -83,6 +84,7 @@ type ManagerInterface interface {
8384
type Manager struct {
8485
balancefetcher.BalanceFetcher
8586
db *sql.DB
87+
settings *settings.Database
8688
RPCClient rpc.ClientInterface
8789
ContractMaker *contracts.ContractMaker
8890
networkManager network.ManagerInterface
@@ -113,6 +115,8 @@ func NewTokenManager(
113115
) *Manager {
114116
maker, _ := contracts.NewContractMaker(RPCClient)
115117

118+
settings, err := settings.MakeNewDB(appDB)
119+
116120
tokensLists, err := tokenlists.NewTokenLists(appDB, db)
117121
if err != nil {
118122
logutils.ZapLogger().Error("Failed to create token lists", zap.Error(err))
@@ -122,6 +126,7 @@ func NewTokenManager(
122126
return &Manager{
123127
BalanceFetcher: balancefetcher.NewDefaultBalanceFetcher(maker),
124128
db: db,
129+
settings: settings,
125130
RPCClient: RPCClient,
126131
ContractMaker: maker,
127132
networkManager: networkManager,
@@ -140,9 +145,15 @@ func (tm *Manager) Start(ctx context.Context, autoRefreshInterval time.Duration,
140145
tm.stopCh = make(chan struct{})
141146
tm.startAccountsWatcher()
142147

148+
thirdpartyServicesEnabled, err := tm.settings.ThirdpartyServicesEnabled()
149+
if err != nil {
150+
logutils.ZapLogger().Error("failed to get if thirdparty services are enabled", zap.Error(err))
151+
return
152+
}
153+
143154
// For now we don't have the list of tokens lists remotely set so we're uisng the harcoded default lists. Once we have it
144155
//we will just need to update the empty string with the correct URL.
145-
tm.tokenLists.Start(ctx, fetcher.RemoteListOfTokenLists, autoRefreshInterval, autoRefreshCheckInterval)
156+
tm.tokenLists.Start(ctx, fetcher.RemoteListOfTokenLists, autoRefreshInterval, autoRefreshCheckInterval, thirdpartyServicesEnabled)
146157
}
147158

148159
func (tm *Manager) startAccountsWatcher() {

0 commit comments

Comments
 (0)