Skip to content

Commit 750ce0e

Browse files
committed
fix: add separate Starknet token grouping step by coinGeckoId
1 parent d9ef09c commit 750ce0e

File tree

1 file changed

+40
-1
lines changed
  • apps/extension/src/stores/huge-queries

1 file changed

+40
-1
lines changed

apps/extension/src/stores/huge-queries/index.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,8 @@ export class HugeQueriesStore {
10861086
// - 토큰의 recommendedSymbol이 이미 존재하는 그룹의 coinDenom과 일치하면(ERC20 그룹) 해당 그룹에 추가
10871087
// - 일치하는 그룹이 없으면 recommendedSymbol을 키로 새 그룹 생성
10881088
// 3. BTC 토큰들은 linkedChainKey를 키로 그룹화
1089-
// 4. 나머지 Unknown 토큰들은 단일 그룹으로 처리
1089+
// 4. Starknet 메인넷 토큰들은 coinGeckoId로 그룹화
1090+
// 5. 나머지 Unknown 토큰들은 단일 그룹으로 처리
10901091
@computed
10911092
get groupedTokensMap(): Map<string, ViewToken[]> {
10921093
const tokensMap = new Map<string, ViewToken[]>();
@@ -1176,6 +1177,29 @@ export class HugeQueriesStore {
11761177
}
11771178
}
11781179

1180+
// Starknet
1181+
for (const viewToken of allKnownBalances) {
1182+
if (processedTokens.has(viewToken)) {
1183+
continue;
1184+
}
1185+
1186+
const modularChainInfo = viewToken.chainInfo;
1187+
1188+
if ("starknet" in modularChainInfo && !modularChainInfo.isTestnet) {
1189+
const currency = viewToken.token.currency;
1190+
1191+
if (currency.coinGeckoId) {
1192+
const groupKey = this.findGroupKeyByCoinGeckoId(
1193+
currency.coinGeckoId,
1194+
tokensMap
1195+
);
1196+
1197+
this.addTokenToGroup(groupKey, viewToken, tokensMap);
1198+
processedTokens.set(viewToken, true);
1199+
}
1200+
}
1201+
}
1202+
11791203
// Unknown
11801204
for (const viewToken of allKnownBalances) {
11811205
if (processedTokens.has(viewToken)) {
@@ -1341,6 +1365,21 @@ export class HugeQueriesStore {
13411365
return `erc20:${recommendedSymbol}/${coinGeckoId}`;
13421366
}
13431367

1368+
protected findGroupKeyByCoinGeckoId(
1369+
coinGeckoId: string,
1370+
tokensMap: Map<string, ViewToken[]>
1371+
): string {
1372+
for (const [key, viewTokens] of tokensMap.entries()) {
1373+
if (viewTokens.length === 0) continue;
1374+
1375+
if (viewTokens[0].token.currency.coinGeckoId === coinGeckoId) {
1376+
return key;
1377+
}
1378+
}
1379+
1380+
return coinGeckoId;
1381+
}
1382+
13441383
protected addTokenToGroup(
13451384
groupKey: string,
13461385
token: ViewToken,

0 commit comments

Comments
 (0)