From b2257d2ca1f702846a2933e5c1f332276d52e5f5 Mon Sep 17 00:00:00 2001 From: saml33 Date: Tue, 3 Jan 2023 22:06:37 +1100 Subject: [PATCH] add active connect buttons --- components/BorrowForm.tsx | 8 ++++--- components/DepositForm.tsx | 10 ++++----- components/RepayForm.tsx | 5 ++--- components/WithdrawForm.tsx | 10 ++++----- components/account/ActivityFeedTable.tsx | 7 +++--- components/shared/ConnectEmptyState.tsx | 24 +++++++++++++++++++++ components/swap/SwapForm.tsx | 8 +++++-- components/swap/SwapHistoryTable.tsx | 7 +++--- components/trade/AdvancedTradeForm.tsx | 27 +++++++++++++++++------- components/trade/OpenOrders.tsx | 7 +++--- components/trade/PerpPositions.tsx | 8 +++---- components/trade/TradeHistory.tsx | 8 +++---- components/trade/UnsettledTrades.tsx | 8 +++---- 13 files changed, 87 insertions(+), 50 deletions(-) create mode 100644 components/shared/ConnectEmptyState.tsx diff --git a/components/BorrowForm.tsx b/components/BorrowForm.tsx index b9e4722a..dcbb723a 100644 --- a/components/BorrowForm.tsx +++ b/components/BorrowForm.tsx @@ -39,6 +39,7 @@ import useJupiterMints from 'hooks/useJupiterMints' import useMangoGroup from 'hooks/useMangoGroup' import TokenVaultWarnings from '@components/shared/TokenVaultWarnings' import { useWallet } from '@solana/wallet-adapter-react' +import { useEnhancedWallet } from './wallet/EnhancedWalletProvider' interface BorrowFormProps { onSuccess: () => void @@ -58,6 +59,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) { const { mangoTokens } = useJupiterMints() const { mangoAccount } = useMangoAccount() const { connected } = useWallet() + const { handleConnect } = useEnhancedWallet() const bank = useMemo(() => { const group = mangoStore.getState().group @@ -113,7 +115,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) { setShowTokenList(false) } - const handleWithdraw = async () => { + const handleBorrow = async () => { const client = mangoStore.getState().client const group = mangoStore.getState().group const mangoAccount = mangoStore.getState().mangoAccount.current @@ -392,9 +394,9 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) { ) : null} + + ) +} + +export default ConnectEmptyState diff --git a/components/swap/SwapForm.tsx b/components/swap/SwapForm.tsx index e7a8bf40..8dfa68fa 100644 --- a/components/swap/SwapForm.tsx +++ b/components/swap/SwapForm.tsx @@ -46,6 +46,7 @@ import MaxSwapAmount from './MaxSwapAmount' import PercentageSelectButtons from './PercentageSelectButtons' import useIpAddress from 'hooks/useIpAddress' import Checkbox from '@components/forms/Checkbox' +import { useEnhancedWallet } from '@components/wallet/EnhancedWalletProvider' const MAX_DIGITS = 11 export const withValueLimit = (values: NumberFormatValues): boolean => { @@ -498,17 +499,20 @@ const SwapFormSubmitButton = ({ const { t } = useTranslation('common') const { connected } = useWallet() const { amount: tokenMax, amountWithBorrow } = useTokenMax(useMargin) + const { handleConnect } = useEnhancedWallet() const showInsufficientBalance = useMargin ? amountWithBorrow.lt(amountIn) : tokenMax.lt(amountIn) const disabled = - !amountIn.toNumber() || !connected || showInsufficientBalance || !amountOut + connected && (!amountIn.toNumber() || showInsufficientBalance || !amountOut) + + const onClick = connected ? () => setShowConfirm(true) : handleConnect return (