diff --git a/hooks/useWallet.tsx b/hooks/useWallet.tsx index 999ee0a7..06921a82 100644 --- a/hooks/useWallet.tsx +++ b/hooks/useWallet.tsx @@ -116,14 +116,15 @@ export default function useWallet() { actions.reloadOrders() actions.fetchTradeHistory() actions.fetchWalletTokens() - notify({ - title: t('wallet-connected'), - description: - t('connected-to') + - wallet.publicKey.toString().substr(0, 5) + - '...' + - wallet.publicKey.toString().substr(-5), - }) + + // notify({ + // title: t('wallet-connected'), + // description: + // t('connected-to') + + // wallet.publicKey.toString().substr(0, 5) + + // '...' + + // wallet.publicKey.toString().substr(-5), + // }) }) wallet.on('disconnect', () => { console.log('disconnecting wallet') @@ -138,16 +139,6 @@ export default function useWallet() { title: t('wallet-disconnected'), }) }) - return () => { - if (wallet && wallet.connected) { - console.log('DISCONNECTING') - - wallet.disconnect() - } - setMangoStore((state) => { - state.wallet.connected = false - }) - } }, [wallet, setMangoStore]) useInterval(() => { diff --git a/pages/account.tsx b/pages/account.tsx index 0ff0ed62..5bc77ca2 100644 --- a/pages/account.tsx +++ b/pages/account.tsx @@ -74,6 +74,12 @@ export default function Account() { setShowNameModal(false) }, []) + useEffect(() => { + // Will either automatically connect to Phantom, or do nothing. + // @ts-ignore + window.solana.connect({ onlyIfTrusted: true }) + }, []) + useEffect(() => { async function loadUnownedMangoAccount() { try { diff --git a/pages/borrow.tsx b/pages/borrow.tsx index b4fa1861..aab5b825 100644 --- a/pages/borrow.tsx +++ b/pages/borrow.tsx @@ -1,4 +1,4 @@ -import { useCallback, useState } from 'react' +import { useCallback, useState, useEffect } from 'react' import { CurrencyDollarIcon, LinkIcon } from '@heroicons/react/outline' import useMangoStore from '../stores/useMangoStore' import PageBodyContainer from '../components/PageBodyContainer' @@ -33,6 +33,12 @@ export default function Borrow() { setShowAccountsModal(false) }, []) + useEffect(() => { + // Will either automatically connect to Phantom, or do nothing. + // @ts-ignore + window.solana.connect({ onlyIfTrusted: true }) + }, []) + return (
diff --git a/pages/stats.tsx b/pages/stats.tsx index 21caa4a2..c72590b9 100644 --- a/pages/stats.tsx +++ b/pages/stats.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useState, useEffect } from 'react' import TopBar from '../components/TopBar' import PageBodyContainer from '../components/PageBodyContainer' import StatsTotals from '../components/stats_page/StatsTotals' @@ -45,6 +45,12 @@ export default function StatsPage() { setActiveTab(tabName) } + useEffect(() => { + // Will either automatically connect to Phantom, or do nothing. + // @ts-ignore + window.solana.connect({ onlyIfTrusted: true }) + }, []) + return (