Skip to content

Commit 7058907

Browse files
committed
fix: prevent duplicate native token address in token prices API request
1 parent 68aced1 commit 7058907

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/assets-controllers/src/CurrencyRateController.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ describe('CurrencyRateController', () => {
12971297
expect(fetchTokenPricesSpy).toHaveBeenCalledTimes(1);
12981298
expect(fetchTokenPricesSpy).toHaveBeenCalledWith({
12991299
chainId: '0x1', // First chainId with ETH as native currency
1300-
tokenAddresses: ['0x0000000000000000000000000000000000000000'],
1300+
tokenAddresses: [],
13011301
currency: 'usd',
13021302
});
13031303

@@ -1518,7 +1518,7 @@ describe('CurrencyRateController', () => {
15181518
expect(fetchTokenPricesSpy).toHaveBeenCalledTimes(1);
15191519
expect(fetchTokenPricesSpy).toHaveBeenCalledWith({
15201520
chainId: '0x1',
1521-
tokenAddresses: ['0x0000000000000000000000000000000000000000'],
1521+
tokenAddresses: [],
15221522
currency: 'usd',
15231523
});
15241524

@@ -1598,7 +1598,7 @@ describe('CurrencyRateController', () => {
15981598
// Should use Polygon's native token address (line 269)
15991599
expect(fetchTokenPricesSpy).toHaveBeenCalledWith({
16001600
chainId: '0x89',
1601-
tokenAddresses: ['0x0000000000000000000000000000000000001010'],
1601+
tokenAddresses: [],
16021602
currency: 'usd',
16031603
});
16041604

packages/assets-controllers/src/CurrencyRateController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ export class CurrencyRateController extends StaticIntervalPollingController<Curr
257257
const ratesResults = await Promise.allSettled(
258258
currencyToChainIdsEntries.map(async ([nativeCurrency, { chainId }]) => {
259259
const nativeTokenAddress = getNativeTokenAddress(chainId);
260+
// Pass empty array as fetchTokenPrices automatically includes the native token address
260261
const tokenPrices = await this.#tokenPricesService.fetchTokenPrices({
261262
chainId,
262-
tokenAddresses: [nativeTokenAddress],
263+
tokenAddresses: [],
263264
currency: currentCurrency,
264265
});
265266

0 commit comments

Comments
 (0)