Skip to content

Commit 88ee14d

Browse files
committed
u2
1 parent 387aee7 commit 88ee14d

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

services/communitytokens/communitytokensdatabase/database.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (db *Database) GetTokenPrivilegesLevel(chainID uint64, contractAddress stri
4747
}
4848

4949
func (db *Database) GetTokens() ([]*token.CommunityToken, error) {
50-
rows, err := db.db.Query(`SELECT community_id, address, name, symbol, chain_id, decimals, type FROM community_tokens`)
50+
rows, err := db.db.Query(`SELECT community_id, address, name, symbol, chain_id, decimals, type, image_base64 FROM community_tokens`)
5151
if err != nil {
5252
return nil, err
5353
}
@@ -56,7 +56,7 @@ func (db *Database) GetTokens() ([]*token.CommunityToken, error) {
5656
var result []*token.CommunityToken
5757
for rows.Next() {
5858
token := token.CommunityToken{}
59-
err := rows.Scan(&token.CommunityID, &token.Address, &token.Name, &token.Symbol, &token.ChainID, &token.Decimals, &token.TokenType)
59+
err := rows.Scan(&token.CommunityID, &token.Address, &token.Name, &token.Symbol, &token.ChainID, &token.Decimals, &token.TokenType, &token.Base64Image)
6060
if err != nil {
6161
return nil, err
6262
}

services/wallet/token/community_token.go

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -132,34 +132,11 @@ func (tm *Manager) getDiscoveredTokens(onlyCommunityCustoms bool) ([]*tokentypes
132132
}
133133

134134
func (tm *Manager) GetCustoms(onlyCommunityCustoms bool) ([]*tokentypes.Token, error) {
135-
communityTokens, err := tm.communityTokensDB.GetTokens()
136-
if err != nil {
137-
return nil, err
138-
}
139-
140135
var (
141136
result []*tokentypes.Token
142137
processedToken = make(map[string]struct{})
143138
)
144139

145-
for _, communityToken := range communityTokens {
146-
token := &tokentypes.Token{
147-
Token: &types.Token{
148-
Address: common.HexToAddress(communityToken.Address),
149-
Name: communityToken.Name,
150-
Symbol: communityToken.Symbol,
151-
Decimals: uint(communityToken.Decimals),
152-
ChainID: uint64(communityToken.ChainID),
153-
},
154-
CommunityData: &tokentypes.CommunityData{
155-
ID: communityToken.CommunityID,
156-
},
157-
}
158-
159-
processedToken[token.Key()] = struct{}{}
160-
result = append(result, token)
161-
}
162-
163140
discoveredTokens, err := tm.getDiscoveredTokens(onlyCommunityCustoms)
164141
if err != nil {
165142
return nil, err
@@ -173,6 +150,32 @@ func (tm *Manager) GetCustoms(onlyCommunityCustoms bool) ([]*tokentypes.Token, e
173150
result = append(result, discoveredToken)
174151
}
175152

153+
if onlyCommunityCustoms {
154+
communityTokens, err := tm.communityTokensDB.GetTokens()
155+
if err != nil {
156+
return nil, err
157+
}
158+
159+
for _, communityToken := range communityTokens {
160+
token := &tokentypes.Token{
161+
Token: &types.Token{
162+
Address: common.HexToAddress(communityToken.Address),
163+
Name: communityToken.Name,
164+
Symbol: communityToken.Symbol,
165+
Decimals: uint(communityToken.Decimals),
166+
ChainID: uint64(communityToken.ChainID),
167+
LogoURI: communityToken.Base64Image,
168+
},
169+
CommunityData: &tokentypes.CommunityData{
170+
ID: communityToken.CommunityID,
171+
},
172+
}
173+
174+
processedToken[token.Key()] = struct{}{}
175+
result = append(result, token)
176+
}
177+
}
178+
176179
return result, nil
177180
}
178181

0 commit comments

Comments
 (0)