11import { toChecksumHexAddress } from '@metamask/controller-utils' ;
22// @ts -expect-error: No type definitions for '@metamask/slip44'
3- import slip44 from '@metamask/slip44' ;
3+ import slip44data from '@metamask/slip44' ;
44import type { CaipAssetType , CaipChainId , Hex } from '@metamask/utils' ;
55import {
66 isCaipAssetType ,
@@ -13,11 +13,11 @@ import { getChainById } from 'eth-chainlist';
1313
1414import { nativeTokenAddress } from '../constants.js' ;
1515
16- const slip44CoinTypeBySymbol = ( ( ) : Map < string , string > => {
16+ const slip44BySymbol = ( ( ) : Map < string , string > => {
1717 const coinTypeBySymbol = new Map < string , string > ( ) ;
1818
1919 for ( const [ coinType , entry ] of Object . entries (
20- slip44 as Record < string , { symbol : string } > ,
20+ slip44data as Record < string , { symbol : string } > ,
2121 ) ) {
2222 const normalizedSymbol = entry . symbol . toUpperCase ( ) ;
2323
@@ -26,14 +26,13 @@ const slip44CoinTypeBySymbol = ((): Map<string, string> => {
2626 }
2727 }
2828
29- // Polygon rebrand: POL shares MATIC's slip44 coin type.
3029 coinTypeBySymbol . set ( 'POL' , coinTypeBySymbol . get ( 'MATIC' ) as string ) ;
3130
3231 return coinTypeBySymbol ;
3332} ) ( ) ;
3433
35- function slip44CoinTypeForSymbol ( symbol : string ) : string | undefined {
36- return slip44CoinTypeBySymbol . get ( symbol . toUpperCase ( ) ) ;
34+ function getCoinType ( symbol : string ) : string | undefined {
35+ return slip44BySymbol . get ( symbol . toUpperCase ( ) ) ;
3736}
3837
3938/**
@@ -81,7 +80,7 @@ export function resolveNativeAssetId(
8180 return undefined ;
8281 }
8382
84- const coinType = slip44CoinTypeForSymbol ( symbol ) ;
83+ const coinType = getCoinType ( symbol ) ;
8584
8685 if ( ! coinType ) {
8786 return undefined ;
@@ -109,15 +108,15 @@ export function getNativeAsset(chainId: CaipChainId):
109108 return undefined ;
110109 }
111110
112- const { nativeCurrency, slip44 : slip44AssetReference } = chain ;
111+ const { nativeCurrency, slip44 } = chain ;
113112 if ( ! nativeCurrency ?. symbol ) {
114113 return undefined ;
115114 }
116115
117116 const assetReference =
118- typeof slip44AssetReference === 'number'
119- ? ` ${ slip44AssetReference } `
120- : slip44CoinTypeForSymbol ( nativeCurrency . symbol ) ;
117+ typeof slip44 === 'number'
118+ ? String ( slip44 )
119+ : getCoinType ( nativeCurrency . symbol ) ;
121120
122121 if ( ! assetReference ) {
123122 return undefined ;
0 commit comments