Skip to content

Commit d8ff44d

Browse files
committed
feat: asset-controller tempo adjustments before migration
1 parent 783f548 commit d8ff44d

6 files changed

Lines changed: 23 additions & 15 deletions

File tree

packages/assets-controller/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
1414
- Bump `@metamask/keyring-controller` from `^25.2.0` to `^25.3.0` ([#8634](https://github.com/MetaMask/core/pull/8634))
1515
- Bump `@metamask/network-controller` from `^30.0.1` to `^30.1.0` ([#8636](https://github.com/MetaMask/core/pull/8636))
16+
- Update `RpcDataSource` to prevent native `getEthBalance` fetching for Tempo chains ([#8638](https://github.com/MetaMask/core/pull/8638))
1617

1718
## [6.2.1]
1819

packages/assets-controller/src/AssetsController.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type {
1212
} from '@metamask/base-controller';
1313
import type { ClientControllerStateChangeEvent } from '@metamask/client-controller';
1414
import { clientControllerSelectors } from '@metamask/client-controller';
15-
import { CHAIN_IDS_WITH_NO_NATIVE_TOKEN } from '@metamask/controller-utils';
1615
import type { TraceCallback } from '@metamask/controller-utils';
1716
import type {
1817
ApiPlatformClient,
@@ -71,6 +70,7 @@ import type {
7170
import type { AccountsApiDataSourceConfig } from './data-sources/AccountsApiDataSource';
7271
import { AccountsApiDataSource } from './data-sources/AccountsApiDataSource';
7372
import { BackendWebsocketDataSource } from './data-sources/BackendWebsocketDataSource';
73+
import { shouldSkipNativeForCaipChainId } from './data-sources/evm-rpc-services/utils/assets';
7474
import type { PriceDataSourceConfig } from './data-sources/PriceDataSource';
7575
import { PriceDataSource } from './data-sources/PriceDataSource';
7676
import type { RpcDataSourceConfig } from './data-sources/RpcDataSource';
@@ -2272,11 +2272,7 @@ export class AssetsController extends BaseController<
22722272
*/
22732273
#shouldHideNativeToken(chainId: ChainId, metadata: AssetMetadata): boolean {
22742274
// Check if it's a chain that should skip native tokens
2275-
if (
2276-
!CHAIN_IDS_WITH_NO_NATIVE_TOKEN.includes(
2277-
chainId as (typeof CHAIN_IDS_WITH_NO_NATIVE_TOKEN)[number],
2278-
)
2279-
) {
2275+
if (!shouldSkipNativeForCaipChainId(chainId)) {
22802276
return false;
22812277
}
22822278

packages/assets-controller/src/data-sources/RpcDataSource.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import type {
6060
BalanceFetchResult,
6161
TokenDetectionResult,
6262
} from './evm-rpc-services/types';
63+
import { shouldSkipNativeForCaipChainId } from './evm-rpc-services/utils/assets';
6364

6465
const CONTROLLER_NAME = 'RpcDataSource';
6566
const DEFAULT_BALANCE_INTERVAL = 30_000; // 30 seconds
@@ -919,12 +920,13 @@ export class RpcDataSource extends AbstractDataSource<
919920

920921
for (const chainId of chainsForAccount) {
921922
const hexChainId = caipChainIdToHex(chainId);
922-
923-
// Build a single AssetFetchEntry[] for native + custom ERC-20s
924923
const nativeAssetId = this.#getNativeAssetForChain(chainId);
925-
const assetsToFetch: AssetFetchEntry[] = [
926-
{ assetId: nativeAssetId, address: ZERO_ADDRESS },
927-
];
924+
925+
const assetsToFetch: AssetFetchEntry[] = [];
926+
if (!shouldSkipNativeForCaipChainId(chainId)) {
927+
// Build a single AssetFetchEntry[] for native + custom ERC-20s
928+
assetsToFetch.push({ assetId: nativeAssetId, address: ZERO_ADDRESS });
929+
}
928930

929931
if (request.customAssets) {
930932
const existingMetadata = this.#getExistingAssetsMetadata();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { CHAIN_IDS_WITH_NO_NATIVE_TOKEN } from '@metamask/controller-utils';
2+
import { CaipChainId } from '@metamask/utils';
3+
4+
export function shouldSkipNativeForCaipChainId(
5+
caipChainId: CaipChainId,
6+
): boolean {
7+
return (CHAIN_IDS_WITH_NO_NATIVE_TOKEN as readonly string[]).includes(
8+
caipChainId,
9+
);
10+
}

packages/assets-controllers/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
1717
- Bump `@metamask/keyring-controller` from `^25.2.0` to `^25.3.0` ([#8634](https://github.com/MetaMask/core/pull/8634))
1818
- Bump `@metamask/network-controller` from `^30.0.1` to `^30.1.0` ([#8636](https://github.com/MetaMask/core/pull/8636))
19+
- Modify `SPOT_PRICES_SUPPORT_INFO` entries for Tempo chains (`0x1079` and `0xa5bf`) ([#8638](https://github.com/MetaMask/core/pull/8638))
1920

2021
## [105.0.0]
2122

packages/assets-controllers/src/token-prices-service/codefi-v2.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ const chainIdToNativeTokenAddress: Record<Hex, Hex> = {
233233
'0x64': '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d', // Gnosis
234234
'0x1e': '0x542fda317318ebf1d3deaf76e0b632741a7e677d', // Rootstock Mainnet - Native symbol: RBTC
235235
'0x3dc': '0x779ded0c9e1022225f8e0630b35a9b54be713736', // Stable - Native symbol: USDT0
236-
'0x1079': '0x20c0000000000000000000000000000000000000', // Tempo Mainnet - Pseudo-Native symbol: pathUSD
237-
'0xa5bf': '0x20c0000000000000000000000000000000000000', // Tempo Moderato Testnet - Pseudo-Native symbol: pathUSD
238236
};
239237

240238
/**
@@ -289,7 +287,7 @@ export const SPOT_PRICES_SUPPORT_INFO = {
289287
'0x74c': 'eip155:1868/erc20:0x0000000000000000000000000000000000000000', // Soneium - Native symbol: ETH
290288
'0xa729': 'eip155:42793/erc20:0x0000000000000000000000000000000000000000', // Etherlink - Native symbol: XTZ (Tezos L2)
291289
'0xab5': 'eip155:2741/erc20:0x0000000000000000000000000000000000000000', // Abstract - Native symbol: ETH
292-
'0x1079': 'eip155:4217/erc20:0x20c0000000000000000000000000000000000000', // Tempo Mainnet - Pseudo-Native symbol: pathUSD
290+
'0x1079': 'eip155:4217/slip44:60', // Tempo Mainnet - No native asset
293291
'0x10e6': 'eip155:4326/erc20:0x0000000000000000000000000000000000000000', // MegaETH Mainnet - Native symbol: ETH
294292
'0x1388': 'eip155:5000/erc20:0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // Mantle - Native symbol: MNT
295293
'0x2105': 'eip155:8453/slip44:60', // Base - Native symbol: ETH
@@ -302,7 +300,7 @@ export const SPOT_PRICES_SUPPORT_INFO = {
302300
'0xa516': 'eip155:42262/slip44:474', // Oasis Emerald - Native symbol: ROSE
303301
'0xa867': 'eip155:43111/erc20:0x0000000000000000000000000000000000000000', // Hemi - Native symbol: ETH
304302
'0xa86a': 'eip155:43114/slip44:9005', // Avalanche C-Chain - Native symbol: AVAX
305-
'0xa5bf': 'eip155:42431/erc20:0x20c0000000000000000000000000000000000000', // Tempo Testnet Moderato - Pseudo-Native symbol: pathUSD
303+
'0xa5bf': 'eip155:42431/slip44:60', // Tempo Testnet Moderato - No native asset
306304
'0xe708': 'eip155:59144/slip44:60', // Linea Mainnet - Native symbol: ETH
307305
'0xed88': 'eip155:60808/erc20:0x0000000000000000000000000000000000000000', // BOB - Native symbol: ETH
308306
'0x138de': 'eip155:80094/erc20:0x0000000000000000000000000000000000000000', // Berachain - Native symbol: Bera',

0 commit comments

Comments
 (0)