import { CommonWalletOptions , Helpers , WalletModule } from '../../../interfaces' ; import { extensionInstallMessage , mobileWalletInstallMessage } from '../content' ; import { binanceChainWalletLogo } from '../wallet-icons/icon-binance-chain-wallet' ; function binanceChainWallet ( options ) { const { preferred , label , iconSrc , svg , isMobile } = options ; return { name : label || 'Binance Chain Wallet' , iconSrc : iconSrc || binanceChainWalletLogo , iconSrcSet : iconSrc || binanceChainWalletLogo , svg : svg || binanceChainWalletLogo , wallet : async ( helpers ) => { const { createModernProviderInterface } = helpers ; const provider = ( window as any ) . BinanceChain ; let providerInterface = null ; let address ; if ( provider ) { providerInterface = createModernProviderInterface ( provider ) ; if ( providerInterface . balance . get ) { if ( providerInterface . address . get ) { const addressGet = providerInterface . address . get ; providerInterface . address . get = async ( ) => { address = await addressGet ( ) ; return address ; } ; } else if ( providerInterface . address . onChange ) { providerInterface . address . onChange ( updatedAddress => { address = updatedAddress ; } ) ; } const balanceGet = providerInterface . balance . get ; providerInterface . balance . get = ( ) => { return address ? balanceGet ( ) : Promise . resolve ( null ) ; } ; } } return { provider , interface : providerInterface } ; } , type : 'injected' , link : 'https://docs.binance.org/smart-chain/wallet/binance.html#download-link' , installMessage : isMobile ? mobileWalletInstallMessage : extensionInstallMessage , desktop : true , mobile : false , preferred } ; } export default binanceChainWallet ;