import HelpIcon from '../../../asset/icon/Help.svg'; import SendIcon from '../../../asset/icon/Send.svg'; import DeflyWalletLogo from '../../../asset/icon/DeflyWallet.svg'; import { DEFLY_WALLET_CONNECT_MODAL_ID, removeModalWrapperFromDOM } from '../../deflyWalletConnectModalUtils'; import styles from './_defly-wallet-connect-modal-pending-message.scss'; import { isIOS } from '../../../util/device/deviceUtils'; import { CONNECT_AUDIO_URL, CONNECT_TIMEOUT_INTERVAL } from './util/deflyWalletConnectModalPendingMessageConstants'; const deflyWalletConnectModalPendingMessageTemplate = document.createElement('template'); deflyWalletConnectModalPendingMessageTemplate.innerHTML = `
Defly Wallet Logo
Please wait while we connect you to Defly Wallet...
`; const deflyWalletConnectTryAgainView = `
Defly Wallet

Couldn’t establish connection

Having issues? Before trying again, make sure to read the support article below and apply the possible solutions.

Help Icon

Resolving WalletConnect issues

Send Icon

Unfortunately there are several known issues related to WalletConnect that our team is working on. Some of these issues are related to the WalletConnect JavaScript implementation on the dApp ...

`; export class DeflyWalletConnectModalPendingMessageSection extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); if (this.shadowRoot) { const styleSheet = document.createElement('style'); styleSheet.textContent = styles; this.shadowRoot.append( deflyWalletConnectModalPendingMessageTemplate.content.cloneNode(true), styleSheet ); } } connectedCallback() { const cancelButton = this.shadowRoot?.getElementById( 'defly-wallet-connect-modal-pending-message-cancel-button' ); cancelButton?.addEventListener('click', () => { this.onClose(); }); this.addAudioForConnection(); setTimeout(() => { deflyWalletConnectModalPendingMessageTemplate.innerHTML = deflyWalletConnectTryAgainView; if (this.shadowRoot) { const styleSheet = document.createElement('style'); styleSheet.textContent = styles; this.shadowRoot.innerHTML = ''; this.shadowRoot.append( deflyWalletConnectModalPendingMessageTemplate.content.cloneNode(true), styleSheet ); const tryAgainButton = this.shadowRoot?.getElementById( 'defly-wallet-connect-modal-pending-message-try-again-button' ); tryAgainButton?.addEventListener('click', () => { this.onClose(); }); } }, CONNECT_TIMEOUT_INTERVAL); } onClose() { removeModalWrapperFromDOM(DEFLY_WALLET_CONNECT_MODAL_ID); } addAudioForConnection() { const shouldUseSound = this.getAttribute('should-use-sound'); if (shouldUseSound === 'true' && isIOS()) { const connectAudioWrapper = this.shadowRoot?.getElementById( 'defly-wallet-connect-modal-pending-message-audio-wrapper' ); const audio = document.createElement('audio'); audio.src = CONNECT_AUDIO_URL; audio.autoplay = true; audio.loop = true; connectAudioWrapper?.appendChild(audio); } } }