Skip to content

Commit 119e1b7

Browse files
committed
feat: a new token list approach - wallet sdk token lists integration
1 parent f3a20c5 commit 119e1b7

File tree

109 files changed

+5378
-31848
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+5378
-31848
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,6 @@ pkg/sentry/SENTRY_PRODUCTION
131131
# Don't ignore generated files in the vendor/ directory
132132
!vendor/**/*.pb.go
133133
!vendor/**/migrations.go
134+
services/wallet/token/local-token-lists/default-lists/status.go
135+
services/wallet/token/local-token-lists/default-lists/coingecko_*.go
136+
services/wallet/token/local-token-lists/default-lists/uniswap.go

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ status-go-deps:
180180

181181

182182
statusgo-library: generate
183+
statusgo-library: download-tokens
183184
statusgo-library: $(LIBWAKU) ##@cross-compile Build status-go as static library for current platform
184185
## cmd/library/README.md explains the magic incantation behind this
185186
mkdir -p build/bin/statusgo-lib
@@ -197,6 +198,7 @@ statusgo-library: $(LIBWAKU) ##@cross-compile Build status-go as static library
197198
build-libwaku: $(LIBWAKU)
198199

199200
statusgo-shared-library: generate
201+
statusgo-shared-library: download-tokens
200202
statusgo-shared-library: $(LIBWAKU) ##@cross-compile Build status-go as shared library for current platform
201203
## cmd/library/README.md explains the magic incantation behind this
202204
mkdir -p build/bin/statusgo-lib
@@ -252,9 +254,10 @@ generate: ##@ Run generate for all given packages using go-generate-fast, fallb
252254
generate-contracts:
253255
go generate ./contracts
254256
download-tokens:
255-
go run ./services/wallet/token/token-lists/default-lists/downloader/main.go
257+
@echo "Downloading token lists..."
258+
go run ./services/wallet/token/local-token-lists/default-lists/downloader/main.go
256259
analyze-token-stores:
257-
go run ./services/wallet/token/token-lists/analyzer/main.go
260+
go run ./services/wallet/token/local-token-lists/analyzer/main.go
258261

259262
prepare-release: clean-release
260263
mkdir -p $(RELEASE_DIR)

contracts/snt/address.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ import (
99
var errorNotAvailableOnChainID = errors.New("not available for chainID")
1010

1111
var contractAddressByChainID = map[uint64]common.Address{
12-
1: common.HexToAddress("0x744d70fdbe2ba4cf95131626614a1763df805b9e"), // mainnet
13-
11155111: common.HexToAddress("0xE452027cdEF746c7Cd3DB31CB700428b16cD8E51"), // sepolia
12+
1: common.HexToAddress("0x744d70fdbe2ba4cf95131626614a1763df805b9e"), // mainnet
13+
10: common.HexToAddress("0x650af3c15af43dcb218406d30784416d64cfb6b2"), // optimism
14+
8453: common.HexToAddress("0x662015ec830df08c0fc45896fab726542e8ac09e"), // base
15+
42161: common.HexToAddress("0x707f635951193ddafbb40971a0fcaab8a6415160"), // arbitrum
16+
11155111: common.HexToAddress("0xE452027cdEF746c7Cd3DB31CB700428b16cD8E51"), // sepolia
17+
84532: common.HexToAddress("0xfdb3b57944943a7724fcc0520ee2b10659969a06"), // base testnet
18+
1660990954: common.HexToAddress("0x1c3ac2a186c6149ae7cb4d716ebbd0766e4f898a"), // status testnet
1419
}
1520

1621
func ContractAddress(chainID uint64) (common.Address, error) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ require (
9393
github.com/prometheus/client_model v0.6.1
9494
github.com/schollz/peerdiscovery v1.7.0
9595
github.com/status-im/extkeys v1.3.0
96-
github.com/status-im/go-wallet-sdk v0.0.0-20250902115318-6340846c26ec
96+
github.com/status-im/go-wallet-sdk v0.0.0-20250908092522-15d894a0ffab
9797
github.com/waku-org/go-waku v0.8.1-0.20250825172353-0c3d6dc0a8cc
9898
github.com/waku-org/waku-go-bindings v0.0.0-20250714110306-6feba5b0df4d
9999
github.com/wk8/go-ordered-map/v2 v2.1.7

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,8 +2061,8 @@ github.com/status-im/go-ethereum v1.10.25-status.24 h1:TOLSwMHbJ1KeLAPljVP7o8jmg
20612061
github.com/status-im/go-ethereum v1.10.25-status.24/go.mod h1:kcIyUwKuTYxEXYRTVkvHtV6EyESKuI5EubF3et9cyR8=
20622062
github.com/status-im/go-sqlcipher/v4 v4.5.4-status.3 h1:/73h1w1hUfb3wVyTlNrUIwahZxatgesCHa6lwO57C2M=
20632063
github.com/status-im/go-sqlcipher/v4 v4.5.4-status.3/go.mod h1:mF2UmIpBnzFeBdu/ypTDb/LdbS0nk0dfSN1WUsWTjMA=
2064-
github.com/status-im/go-wallet-sdk v0.0.0-20250902115318-6340846c26ec h1:wnB/Wyk9h04nuUv37B7ZYSTbVSzxVcXGbA2uu7CJnLs=
2065-
github.com/status-im/go-wallet-sdk v0.0.0-20250902115318-6340846c26ec/go.mod h1:/BMjUSCuuV2KJIxLbEleOJ7RL87NybIv9PBTRJvXjb0=
2064+
github.com/status-im/go-wallet-sdk v0.0.0-20250908092522-15d894a0ffab h1:iqemWxEEti4f+Yq9MxP7svbIB9pa0vs5xG7zUbgDpr0=
2065+
github.com/status-im/go-wallet-sdk v0.0.0-20250908092522-15d894a0ffab/go.mod h1:LeiNCtWKrWt5Nuvwtn+1CXaNGkZlWB9FCTMqdAnqJLg=
20662066
github.com/status-im/gomoji v1.1.3-0.20220213022530-e5ac4a8732d4 h1:CtobZoiNdHpx+xurFxnuJ1xsGm3oKMfcZkB3vmomJmA=
20672067
github.com/status-im/gomoji v1.1.3-0.20220213022530-e5ac4a8732d4/go.mod h1:hmpnZzkzSZJbFYWAUkrPV8I36x7mdYiPhPqnALP4fKA=
20682068
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=

nix/pkgs/status-go/library/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ in pkgs.buildGoPackage {
4242
preBuild = ''
4343
pushd go/src/$goPackagePath
4444
go run cmd/library/*.go > $NIX_BUILD_TOP/main.go
45+
make download-tokens SHELL=$SHELL GO111MODULE=on
4546
make generate SHELL=$SHELL GO111MODULE=on GO_GENERATE_CMD='go generate'
4647
popd
4748
'';

node/get_status_node.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,6 @@ func (n *StatusNode) startWithDB(config *params.NodeConfig) error {
334334
}
335335

336336
func (n *StatusNode) createAndStartTokenManager() error {
337-
accDB, err := accounts.NewDB(n.appDB)
338-
if err != nil {
339-
return err
340-
}
341-
342-
n.tokenManager = token.NewTokenManager(n.walletDB, n.rpcClient, community.NewManager(n.appDB, n.httpServer, nil),
343-
n.rpcClient.GetNetworkManager(), n.appDB, n.httpServer, &n.walletFeed, n.accountsPublisher, accDB,
344-
token.NewPersistence(n.walletDB))
345-
346337
const (
347338
defaultAutoRefreshInterval = 30 * time.Minute // interval after which we should fetch the token lists from the remote source (or use the default one if remote source is not set)
348339
defaultAutoRefreshCheckInterval = 3 * time.Minute // interval after which we should check if we should trigger the auto-refresh
@@ -357,7 +348,19 @@ func (n *StatusNode) createAndStartTokenManager() error {
357348
autoRefreshCheckInterval = time.Duration(n.config.WalletConfig.TokensListsAutoRefreshCheckInterval) * time.Second
358349
}
359350

360-
n.tokenManager.Start(context.Background(), autoRefreshInterval, autoRefreshCheckInterval)
351+
accDB, err := accounts.NewDB(n.appDB)
352+
if err != nil {
353+
return err
354+
}
355+
356+
n.tokenManager, err = token.NewTokenManager(n.walletDB, n.rpcClient, community.NewManager(n.appDB, n.httpServer, nil),
357+
n.rpcClient.GetNetworkManager(), n.appDB, n.httpServer, &n.walletFeed, n.accountsPublisher, accDB,
358+
token.NewPersistence(n.walletDB), autoRefreshInterval, autoRefreshCheckInterval)
359+
if err != nil {
360+
return err
361+
}
362+
363+
n.tokenManager.Start(context.Background())
361364
return nil
362365
}
363366

node/status_node_services.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server
7373
// Wallet Service is used by wakuExtSrvc/wakuV2ExtSrvc
7474
// Keep this initialization before the other two
7575
if config.WalletConfig.Enabled {
76-
walletService := b.walletService(accDB, b.appDB, b.accountsPublisher, &b.walletFeed, config.WalletConfig.StatusProxyStageName)
77-
services = append(services, walletService)
76+
err := b.createWalletService(accDB, b.appDB, b.accountsPublisher, &b.walletFeed, config.WalletConfig.StatusProxyStageName)
77+
if err != nil {
78+
return err
79+
}
80+
services = append(services, b.walletSrvc)
7881
}
7982

8083
// CollectiblesManager needs the WakuExt service to get metadata for
@@ -283,9 +286,9 @@ func (b *StatusNode) SetWalletCommunityInfoProvider(provider thirdparty.Communit
283286
}
284287
}
285288

286-
func (b *StatusNode) walletService(accountsDB *accounts.Database, appDB *sql.DB, accountsPublisher *pubsub.Publisher, walletFeed *event.Feed, statusProxyStageName string) *wallet.Service {
289+
func (b *StatusNode) createWalletService(accountsDB *accounts.Database, appDB *sql.DB, accountsPublisher *pubsub.Publisher, walletFeed *event.Feed, statusProxyStageName string) (err error) {
287290
if b.walletSrvc == nil {
288-
b.walletSrvc = wallet.NewService(
291+
b.walletSrvc, err = wallet.NewService(
289292
b.walletDB, accountsDB, appDB, b.rpcClient, accountsPublisher, b.gethAccountsManager, b.transactor, b.config,
290293
b.ensService(b.timeSourceNow()).API().EnsResolver(),
291294
b.pendingTracker,
@@ -295,7 +298,7 @@ func (b *StatusNode) walletService(accountsDB *accounts.Database, appDB *sql.DB,
295298
statusProxyStageName,
296299
)
297300
}
298-
return b.walletSrvc
301+
return
299302
}
300303

301304
func (b *StatusNode) ethService() *eth.Service {

protocol/communities/manager.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"github.com/pkg/errors"
2323
"go.uber.org/zap"
2424

25+
"github.com/status-im/go-wallet-sdk/pkg/tokenlists"
26+
2527
gethcommon "github.com/ethereum/go-ethereum/common"
2628
"github.com/ethereum/go-ethereum/common/hexutil"
2729

@@ -48,7 +50,6 @@ import (
4850
walletcommon "github.com/status-im/status-go/services/wallet/common"
4951
"github.com/status-im/status-go/services/wallet/thirdparty"
5052
"github.com/status-im/status-go/services/wallet/token"
51-
tokenTypes "github.com/status-im/status-go/services/wallet/token/types"
5253
"github.com/status-im/status-go/signal"
5354
)
5455

@@ -259,7 +260,7 @@ type managerOptions struct {
259260
type TokenManager interface {
260261
GetBalancesByChain(ctx context.Context, accounts, tokens []gethcommon.Address, chainIDs []uint64) (BalancesByChain, error)
261262
GetCachedBalancesByChain(ctx context.Context, accounts, tokenAddresses []gethcommon.Address, chainIDs []uint64) (BalancesByChain, error)
262-
FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) *tokenTypes.Token
263+
FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) *tokenlists.Token
263264
GetAllChainIDs() ([]uint64, error)
264265
}
265266

@@ -340,7 +341,7 @@ func (m *DefaultTokenManager) GetCachedBalancesByChain(ctx context.Context, acco
340341
return resp, nil
341342
}
342343

343-
func (m *DefaultTokenManager) FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) *tokenTypes.Token {
344+
func (m *DefaultTokenManager) FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) *tokenlists.Token {
344345
return m.tokenManager.FindOrCreateTokenByAddress(ctx, chainID, address)
345346
}
346347

protocol/communities/manager_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
gethcommon "github.com/ethereum/go-ethereum/common"
1616
"github.com/ethereum/go-ethereum/common/hexutil"
1717

18+
"github.com/status-im/go-wallet-sdk/pkg/tokenlists"
19+
1820
"github.com/status-im/status-go/appdatabase"
1921
"github.com/status-im/status-go/crypto"
2022
userimages "github.com/status-im/status-go/images"
@@ -30,7 +32,6 @@ import (
3032
"github.com/status-im/status-go/services/wallet/bigint"
3133
walletCommon "github.com/status-im/status-go/services/wallet/common"
3234
"github.com/status-im/status-go/services/wallet/thirdparty"
33-
tokenTypes "github.com/status-im/status-go/services/wallet/token/types"
3435
"github.com/status-im/status-go/t/helpers"
3536

3637
"github.com/golang/protobuf/proto"
@@ -201,7 +202,7 @@ func (m *testTokenManager) GetCachedBalancesByChain(ctx context.Context, account
201202
return m.response, nil
202203
}
203204

204-
func (m *testTokenManager) FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) *tokenTypes.Token {
205+
func (m *testTokenManager) FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) *tokenlists.Token {
205206
return nil
206207
}
207208

0 commit comments

Comments
 (0)