Skip to content

Commit ba794d6

Browse files
committed
feat!: a new token list approach - wallet sdk token lists integration
1 parent b3af095 commit ba794d6

File tree

2,456 files changed

+16954
-157956
lines changed

Some content is hidden

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

2,456 files changed

+16954
-157956
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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,23 @@ generate: export GO_GENERATE_FAST_DEBUG ?= false
292292
generate: export GO_GENERATE_FAST_RECACHE ?= false
293293
generate: ##@ Run generate for all given packages using go-generate-fast, fallback to `go generate` (e.g. for docker)
294294
@GOROOT=$$(go env GOROOT) $(GO_GENERATE_CMD) $(PACKAGES)
295+
make download-tokens
295296

296297
generate-contracts:
297298
go generate ./contracts
299+
298300
download-tokens:
299-
go run ./services/wallet/token/token-lists/default-lists/downloader/main.go
301+
@if [ ! -f services/wallet/token/local-token-lists/default-lists/status.go ] || \
302+
[ ! -f services/wallet/token/local-token-lists/default-lists/uniswap.go ]; then \
303+
echo "Downloading token lists..."; \
304+
GOROOT=$$(go env GOROOT) GOFLAGS="-mod=mod" go run ./services/wallet/token/local-token-lists/default-lists/downloader/main.go; \
305+
echo "token list downloaded successfully"; \
306+
else \
307+
echo "Token lists are already downloaded, skipping download"; \
308+
fi
309+
300310
analyze-token-stores:
301-
go run ./services/wallet/token/token-lists/analyzer/main.go
311+
go run ./services/wallet/token/local-token-lists/analyzer/main.go
302312

303313
prepare-release: clean-release
304314
mkdir -p $(RELEASE_DIR)

api/geth_backend.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
"github.com/imdario/mergo"
2424

25-
"github.com/ethereum/go-ethereum/common"
2625
"github.com/ethereum/go-ethereum/common/hexutil"
2726
ethcrypto "github.com/ethereum/go-ethereum/crypto"
2827
signercore "github.com/ethereum/go-ethereum/signer/core/apitypes"
@@ -2021,7 +2020,7 @@ func (b *GethStatusBackend) SendTransactionWithSignature(sendArgs wallettypes.Se
20212020
return hash, err
20222021
}
20232022

2024-
return b.transactor.SendTransactionWithSignature(common.Address(sendArgs.From), sendArgs.Symbol, txWithSignature)
2023+
return b.transactor.SendTransactionWithSignature(&sendArgs, txWithSignature)
20252024
}
20262025

20272026
// HashTransaction validate the transaction and returns new sendArgs and the transaction hash.

api/protocol_adaptors.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import (
44
"context"
55

66
gethcommon "github.com/ethereum/go-ethereum/common"
7+
8+
"golang.org/x/exp/maps"
9+
710
"github.com/status-im/status-go/protocol/communities"
811
"github.com/status-im/status-go/rpc/network"
912
"github.com/status-im/status-go/services/wallet/token"
10-
tokenTypes "github.com/status-im/status-go/services/wallet/token/types"
13+
tokentypes "github.com/status-im/status-go/services/wallet/token/types"
1114
)
1215

1316
var _ communities.NetworkManager = (*CommunitiesNetworkManager)(nil)
@@ -43,7 +46,7 @@ func NewCommunitiesTokenManager(tm *token.Manager) *CommunitiesTokenManager {
4346
return &CommunitiesTokenManager{tokenManager: tm}
4447
}
4548

46-
func (m *CommunitiesTokenManager) FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) *tokenTypes.Token {
49+
func (m *CommunitiesTokenManager) FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address gethcommon.Address) (*tokentypes.Token, error) {
4750
return m.tokenManager.FindOrCreateTokenByAddress(ctx, chainID, address)
4851
}
4952

@@ -55,18 +58,23 @@ func NewCommunitiesTokenBalanceManager(tm *token.Manager) *CommunitiesTokenBalan
5558
return &CommunitiesTokenBalanceManager{tokenManager: tm}
5659
}
5760

58-
func (m *CommunitiesTokenBalanceManager) GetBalancesByChain(ctx context.Context, accounts, tokenAddresses []gethcommon.Address, chainIDs []uint64) (communities.BalancesByChain, error) {
59-
chainClients, err := m.tokenManager.RPCClient.EthClients(chainIDs)
61+
func (m *CommunitiesTokenBalanceManager) GetBalancesByChain(ctx context.Context, accounts []gethcommon.Address, tokens []*tokentypes.Token) (communities.BalancesByChain, error) {
62+
chainIDs := make(map[uint64]struct{}, 0)
63+
for _, token := range tokens {
64+
chainIDs[token.ChainID] = struct{}{}
65+
}
66+
67+
chainClients, err := m.tokenManager.RPCClient.EthClients(maps.Keys(chainIDs))
6068
if err != nil {
6169
return nil, err
6270
}
6371

64-
resp, err := m.tokenManager.GetBalancesByChain(context.Background(), chainClients, accounts, tokenAddresses)
72+
resp, err := m.tokenManager.GetBalancesByChain(context.Background(), chainClients, accounts, tokens)
6573
return resp, err
6674
}
6775

68-
func (m *CommunitiesTokenBalanceManager) GetCachedBalancesByChain(ctx context.Context, accounts, tokenAddresses []gethcommon.Address, chainIDs []uint64) (communities.BalancesByChain, error) {
69-
resp, err := m.tokenManager.GetCachedBalancesByChain(accounts, tokenAddresses, chainIDs)
76+
func (m *CommunitiesTokenBalanceManager) GetCachedBalancesByChain(ctx context.Context, accounts []gethcommon.Address, tokens []*tokentypes.Token) (communities.BalancesByChain, error) {
77+
resp, err := m.tokenManager.GetCachedBalancesByChain(accounts, tokens)
7078
if err != nil {
7179
return resp, err
7280
}

0 commit comments

Comments
 (0)