Skip to content

Commit 934352f

Browse files
committed
feat!: a new token list approach - wallet sdk token lists integration
1 parent 858d887 commit 934352f

File tree

169 files changed

+18429
-35268
lines changed

Some content is hidden

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

169 files changed

+18429
-35268
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,17 @@ generate: PACKAGES ?= $$(go list -e ./... | grep -v "/contracts/")
288288
generate: GO_GENERATE_CMD ?= $$(which go-generate-fast || echo 'go generate')
289289
generate: export GO_GENERATE_FAST_DEBUG ?= false
290290
generate: export GO_GENERATE_FAST_RECACHE ?= false
291+
generate: download-tokens
291292
generate: ##@ Run generate for all given packages using go-generate-fast, fallback to `go generate` (e.g. for docker)
292293
@GOROOT=$$(go env GOROOT) $(GO_GENERATE_CMD) $(PACKAGES)
293294

294295
generate-contracts:
295296
go generate ./contracts
296297
download-tokens:
297-
go run ./services/wallet/token/token-lists/default-lists/downloader/main.go
298+
@echo "Downloading token lists..."
299+
go run ./services/wallet/token/local-token-lists/default-lists/downloader/main.go
298300
analyze-token-stores:
299-
go run ./services/wallet/token/token-lists/analyzer/main.go
301+
go run ./services/wallet/token/local-token-lists/analyzer/main.go
300302

301303
prepare-release: clean-release
302304
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"
@@ -2023,7 +2022,7 @@ func (b *GethStatusBackend) SendTransactionWithSignature(sendArgs wallettypes.Se
20232022
return hash, err
20242023
}
20252024

2026-
return b.transactor.SendTransactionWithSignature(common.Address(sendArgs.From), sendArgs.Symbol, txWithSignature)
2025+
return b.transactor.SendTransactionWithSignature(&sendArgs, txWithSignature)
20272026
}
20282027

20292028
// 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)