import { CHAINS } from '@/constant' ; import { keyBy } from 'lodash' ; import { browser } from 'webextension-polyfill-ts' ; import BroadcastChannelMessage from './message/broadcastChannelMessage' ; import PortMessage from './message/portMessage' ; const Message = { BroadcastChannelMessage , PortMessage , } ; declare global { const langLocales ; } const t = ( name ) => browser . i18n . getMessage ( name ) ; const format = ( str , ... args ) => { return args . reduce ( ( m , n ) => m . replace ( '_s_' , n ) , str ) ; } ; export { Message , t , format } ; const chainsDict = keyBy ( CHAINS , 'serverId' ) ; export const getChain = ( chainId ? ) => { if ( ! chainId ) { return null ; } return chainsDict [ chainId ] ; } ;