Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect buttons #920

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions apps/dapp/src/components/Pages/Core/DappPages/Legacy/UnstakeOGT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import { formatBigNumber, formatTemple, getBigNumberFromString } from 'component
import { ZERO } from 'utils/bigNumber';
import { useStaking } from 'providers/StakingProvider';
import { BigNumber } from 'ethers';
import { useConnectWallet } from '@web3-onboard/react';
import { TradeButton } from '../../NewUI/Home';

export const UnstakeOGT = () => {
const [{}, connect] = useConnectWallet();
const { wallet, signer, balance, updateBalance } = useWallet();
const [_, refreshWallet] = useRefreshWalletState();
const [unstakeAmount, setUnstakeAmount] = useState<string>('');
Expand Down Expand Up @@ -54,14 +57,24 @@ export const UnstakeOGT = () => {
{lockedEntries.length > 0 ? (
<>
<TopSubtitle>You can claim locked OGTemple from the Opening Ceremony:</TopSubtitle>
<ClaimButton
isSmall
onClick={() => handleUnlockOGT()}
disabled={Date.now() < lockedEntries[0].lockedUntilTimestamp}
>
Claim {formatTemple(lockedEntries.reduce((sum, cur) => sum.add(cur.balanceOGTemple), BigNumber.from('0')))}{' '}
OGTemple
</ClaimButton>
{!wallet ? (
<TradeButton
label={`Connect`}
onClick={() => {
connect();
}}
/>
) : (
<TradeButton
isSmall
onClick={() => handleUnlockOGT()}
disabled={Date.now() < lockedEntries[0].lockedUntilTimestamp}
>
Claim{' '}
{formatTemple(lockedEntries.reduce((sum, cur) => sum.add(cur.balanceOGTemple), BigNumber.from('0')))}{' '}
OGTemple
</TradeButton>
)}
<Subtitle>
{lockedEntries.length > 1 && (
<span>
Expand All @@ -80,9 +93,18 @@ export const UnstakeOGT = () => {
TEMPLE.
</Subtitle>
<ButtonContainer>
<ClaimButton disabled={buttonIsDisabled} onClick={() => unstake(unstakeAmount)}>
Unstake OGTEMPLE
</ClaimButton>
{!wallet ? (
<TradeButton
label={`Connect`}
onClick={() => {
connect();
}}
/>
) : (
<TradeButton disabled={buttonIsDisabled} onClick={() => unstake(unstakeAmount)}>
Unstake OGTEMPLE
</TradeButton>
)}
</ButtonContainer>
</>
)}
Expand Down
21 changes: 16 additions & 5 deletions apps/dapp/src/components/Pages/Core/NewUI/TradeNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useEffect } from 'react';
import { useNotification } from 'providers/NotificationProvider';
import { TransactionPreviewModal } from 'components/TransactionSettingsModal/TransactionPreviewModal';
import { tabletAndAbove } from 'styles/breakpoints';
import { useConnectWallet } from '@web3-onboard/react';

export const Trade = () => {
const {
Expand All @@ -25,6 +26,7 @@ export const Trade = () => {
handleTransaction,
} = useSwapController();

const [{ wallet }, connect] = useConnectWallet();
const [isPreviewModalOpen, setIsPreviewModalOpen] = useState(false);
const [isSlippageModalOpen, setIsSlippageModalOpen] = useState(false);

Expand Down Expand Up @@ -98,11 +100,20 @@ export const Trade = () => {
<AdvancedSettingsButton onClick={() => setIsSlippageModalOpen(true)}>
Advanced Settings
</AdvancedSettingsButton>
<TradeButton
disabled={!state.quote || state.quote.returnAmount.lte(0)}
label="Preview"
onClick={() => setIsPreviewModalOpen(true)}
/>
{!wallet ? (
<TradeButton
label={`Connect`}
onClick={() => {
connect();
}}
/>
) : (
<TradeButton
disabled={!state.quote || state.quote.returnAmount.lte(0)}
label="Preview"
onClick={() => setIsPreviewModalOpen(true)}
/>
)}
</ButtonContainer>
</SwapContainer>
</TradeContainer>
Expand Down
2 changes: 2 additions & 0 deletions apps/dapp/src/providers/WalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export const WalletProvider = (props: PropsWithChildren<object>) => {
} else {
setWalletAddress(undefined);
}
} else {
setWalletAddress(undefined);
}
}, [wallet, connecting]);

Expand Down
Loading