import { DOCUMENT } from '@angular/common' ; import { Inject , Injectable , Injector } from '@angular/core' ; import { ConfigsService } from '../../../../common/services/configs.service' ; import { ModalService } from '../../../composer/components/modal/modal.service' ; import { OnchainTransferModalService } from '../../../wallet/components/components/onchain-transfer/onchain-transfer.service' ; import { EarnModalService } from '../../earn/earn-modal.service' ; import { BuyTokensModalService } from '../../token-purchase/v2/buy-tokens-modal.service' ; import { UniswapModalService } from '../../token-purchase/v2/uniswap/uniswap-modal.service' ; import { Web3WalletService } from '../../web3-wallet.service' ; /**
 * Manages the opening of various modals and links on blockchain marketing pages.
 */ @ Injectable ( { providedIn : 'root' } ) export class BlockchainMarketingLinksService { private siteUrl : string ; constructor ( private composerModal , private injector , private web3WalletService , private buyTokensModalService , private earnModalService , private uniswapModal , private onchainTransferModal , @ Inject ( DOCUMENT ) private document , configs ) { this . siteUrl = configs . get ( 'site_url' ) ; } returns { Promise < BlockchainMarketingLinksService > } public async openBuyTokensModal ( ) { try { await this . web3WalletService . getCurrentWallet ( true ) ; await this . buyTokensModalService . open ( ) ; } catch ( e ) { if ( e === 'Dismissed modal' ) { return this ; } console . error ( e ) ; } return this ; } returns { Promise < BlockchainMarketingLinksService > } public async openEarnModal ( ) { try { await this . earnModalService . open ( ) ; } catch ( e ) { if ( e === 'Dismissed modal' ) { return this ; } console . error ( e ) ; } return this ; } returns { BlockchainMarketingLinksService } public openComposerModal ( ) { try { this . composerModal . setInjector ( this . injector ) . present ( ) . toPromise ( ) ; } catch ( e ) { } return this ; } returns { BlockchainMarketingLinksService } public openTransferOnchainModal ( ) { try { this . onchainTransferModal . setInjector ( this . injector ) . present ( ) . toPromise ( ) ; } catch ( e ) { } return this ; } returns { BlockchainMarketingLinksService } public openAirdropModal ( ) { return this ; } returns { BlockchainMarketingLinksService } public openLiquidityProvisionModal ( ) { this . uniswapModal . open ( 'add' ) ; return this ; } returns { BlockchainMarketingLinksService } public navigateToReferrals ( ) { this . openInNewWindow ( `${ this . siteUrl }settings/other/referrals` ) ; return this ; } returns { BlockchainMarketingLinksService } public navigateToWhitepaper ( ) { this . openInNewWindow ( 'https://cdn-assets.minds.com/front/dist/en/assets/documents/Whitepaper-v0.5.pdf' ) ; return this ; } returns { BlockchainMarketingLinksService } public navigateToTokenAnalytics ( ) { this . openInNewWindow ( '/analytics/dashboard/token/supply' ) ; return this ; } returns { BlockchainMarketingLinksService } public navigateToBlog ( ) { this . openInNewWindow ( `${ this . siteUrl }minds/blogs` ) ; return this ; } returns { BlockchainMarketingLinksService } public navigateToJoinRewards ( ) { this . openInNewWindow ( `${ this . siteUrl }wallet/tokens/balance` ) ; return this ; } param { string } returns { BlockchainMarketingLinksService } private openInNewWindow ( href ) { const link = this . document . createElement ( 'a' ) ; link . target = '_blank' ; link . href = href ; link . click ( ) ; link . remove ( ) ; return this ; } }