Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f30249b
feat(WalletWidget): added Alert component
MatthewCYLau Aug 22, 2022
071d9f3
feat(mockWalletAddressContext): added mockWalletAddressContext
MatthewCYLau Aug 22, 2022
b9cfa76
feat(WalletSelector): added input to wallet selector for mock address
MatthewCYLau Aug 23, 2022
58632a6
feat(WatchOnlyModeTooltip): added WatchOnlyMode tooltip
MatthewCYLau Aug 23, 2022
c9022d5
feat(WalletSelector): use web3 context for set mock adddress
MatthewCYLau Aug 23, 2022
eac8a37
chore(WalletWidget): removed console log
MatthewCYLau Aug 23, 2022
ee9c4c6
chore: merge with latest main
MatthewCYLau Aug 24, 2022
7824af7
feat(WalletWidget): added warning icon
MatthewCYLau Aug 24, 2022
92e0567
chore: updated message.js
MatthewCYLau Aug 24, 2022
aa1a46b
chore: update with main
MatthewCYLau Aug 25, 2022
c293c3f
chore: updated message.js
MatthewCYLau Aug 25, 2022
f57cc68
feat(Web3Provider): updated condition to render Wallet Modal
MatthewCYLau Aug 25, 2022
3a836cc
feat(TxActionsWrapper): render warning text when using mockAddress
MatthewCYLau Aug 26, 2022
87b0d25
chore: updated messages
MatthewCYLau Aug 26, 2022
3c6417a
Merge branch 'main' of https://github.com/MatthewCYLau/interface into…
MatthewCYLau Aug 26, 2022
d5bd722
feat(WalletSelector): use utils to check if mock address is valid
MatthewCYLau Aug 26, 2022
89a6dfa
feat(TxActionsWrapper): disabled button if mockAddress is present
MatthewCYLau Aug 27, 2022
9db5194
chore(cypress.config): added eslint ignore
MatthewCYLau Sep 5, 2022
892e62f
chore: updated message.js
MatthewCYLau Sep 5, 2022
bb3347f
feat: do not render ChangeNetworkWarning when mockAddress is present
MatthewCYLau Sep 5, 2022
7242db2
feat(WalletWidget): added buttons to switch network and disconnect
MatthewCYLau Sep 5, 2022
64f734c
feat(WalletWidget): adjusted margin
MatthewCYLau Sep 5, 2022
b1879d0
chore(WalletWidget): removed Disconnect Wallet button
MatthewCYLau Sep 5, 2022
4c7360e
chore: removed temp value for max amount to borrow
MatthewCYLau Sep 5, 2022
8fd8b89
chore: updated messages.po
MatthewCYLau Sep 5, 2022
e770173
Merge branch 'main' of https://github.com/MatthewCYLau/interface into…
MatthewCYLau Sep 6, 2022
a7bcecc
chore: updated markdown to trigger git delta
MatthewCYLau Sep 6, 2022
9e1b442
chore: reverted changes to Code of Conduct md
MatthewCYLau Sep 6, 2022
6229651
chore: updated with main
MatthewCYLau Sep 8, 2022
a0d9afe
chore: updated message.js
MatthewCYLau Sep 8, 2022
259bc6b
chore: resolved merge conflict
MatthewCYLau Sep 19, 2022
eb7a675
chore: unimport WatchOnlyModeToolTip to ensure message.js is updated
MatthewCYLau Sep 19, 2022
0d8b3b4
chore(cypress.config): removed eslint-disable
MatthewCYLau Sep 19, 2022
bad5b5d
chore(WalletSelector): re-import WatchOnlyModeToolTip
MatthewCYLau Sep 19, 2022
3b89196
feat(WalletWidget): set wallet widget to close when clicking switch w…
MatthewCYLau Sep 19, 2022
dc8b726
feat(Web3Provider): when connect wallet, check and remove mock address
MatthewCYLau Sep 19, 2022
3addedb
feat: if mockAddress is present, do not render approval help text and…
MatthewCYLau Sep 20, 2022
c7d3260
feat: on mobile, if mockAddress is present, render Close menu icon
MatthewCYLau Sep 20, 2022
7315bac
feat(WalletWidget): update styling for warning text in mobile
MatthewCYLau Sep 20, 2022
7b86ef8
feat(WalletWidget): on mobile, render CTAs at list buttom
MatthewCYLau Sep 20, 2022
b1015d3
chore: merged with main
MatthewCYLau Sep 20, 2022
c9d5398
feat(WalletWidget): add color styling to CTAs
MatthewCYLau Sep 20, 2022
a706a30
feat(WalletWidget): styling for avatar icon on mobile
MatthewCYLau Sep 21, 2022
e7f0d8c
chore: updated message.js
MatthewCYLau Sep 21, 2022
934e149
feat(WalletWidget): update styling for warning icon background
MatthewCYLau Sep 21, 2022
895cf0f
feat(WalletWidget): use hideWalletAccountText variable to determine m…
MatthewCYLau Sep 21, 2022
1541aed
chore: merge with main
MatthewCYLau Sep 22, 2022
df2233f
chore(WalletWidget): removed un-used improt
MatthewCYLau Sep 22, 2022
04b9336
feat(WalletWidget): fine-tune warning icon color
MatthewCYLau Sep 22, 2022
4c2831e
feat(WalletWidget): updated styling to background and CTA buttons
MatthewCYLau Sep 24, 2022
99af72f
feat(WalletWidget): added Divider
MatthewCYLau Sep 24, 2022
a4b418a
chore(WalletWidget): updated copy
MatthewCYLau Sep 24, 2022
3bf300e
feat(WalletSelector): use fullWifth props for button
MatthewCYLau Sep 26, 2022
c25eeac
feat(WalletSelector): use fullWidfth props for input
MatthewCYLau Sep 26, 2022
91c0766
feat(WatchOnlyModeTooltip): re-named component with correct casing
MatthewCYLau Sep 26, 2022
4e1e4c2
feat(WalletSelector): added boolean state to check for valid address …
MatthewCYLau Sep 26, 2022
7c8313f
feat(WalletWidget): added handle switch wallet method
MatthewCYLau Sep 26, 2022
42de845
chore: updated messages.js
MatthewCYLau Sep 26, 2022
f6c63d1
feat(useWeb3Context): update setWatchModeOnlyAddress method name
MatthewCYLau Sep 27, 2022
62b2fa2
chore: updated with latest main
MatthewCYLau Sep 28, 2022
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 64 additions & 2 deletions src/components/WalletConnection/WalletSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Trans } from '@lingui/macro';
import { Alert, Box, Button, Link, Typography } from '@mui/material';
import { Alert, Box, Button, InputBase, Link, Typography } from '@mui/material';
import { UnsupportedChainIdError } from '@web3-react/core';
import { NoEthereumProviderError } from '@web3-react/injected-connector';
import { UserRejectedRequestError } from '@web3-react/walletconnect-connector';
import { utils } from 'ethers';
import { useState } from 'react';
import { WatchOnlyModeTooltip } from 'src/components/infoTooltips/WatchOnlyModeTooltip';
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
import { WalletType } from 'src/libs/web3-data-provider/WalletOptions';

Expand Down Expand Up @@ -95,7 +98,9 @@ export enum ErrorType {
}

export const WalletSelector = () => {
const { error } = useWeb3Context();
const { error, setWatchModeOnlyAddress } = useWeb3Context();
const [inputMockWalletAddress, setInputMockWalletAddress] = useState('');
const [validAddressError, setValidAddressError] = useState<boolean>(false);

let blockingError: ErrorType | undefined = undefined;
if (error) {
Expand Down Expand Up @@ -125,6 +130,12 @@ export const WalletSelector = () => {
}
};

const handleWatchAddress = (inputMockWalletAddress: string): void => {
if (validAddressError) setValidAddressError(false);
if (!utils.isAddress(inputMockWalletAddress)) return setValidAddressError(true);
setWatchModeOnlyAddress(inputMockWalletAddress);
};

return (
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
<TxModalTitle title="Connect a wallet" />
Expand All @@ -150,6 +161,57 @@ export const WalletSelector = () => {
/>
<WalletRow key="torus_wallet" walletName="Torus" walletType={WalletType.TORUS} />
<WalletRow key="frame_wallet" walletName="Frame" walletType={WalletType.FRAME} />
<Box sx={{ display: 'flex', alignItems: 'center', mb: 1, padding: '10px 0' }}>
<Typography variant="subheader1" color="text.secondary">
<Trans>Enter an address to track in watch-only mode</Trans>
</Typography>
<WatchOnlyModeTooltip />
</Box>
<Box
sx={(theme) => ({
p: '8px 12px',
border: `1px solid ${theme.palette.divider}`,
borderRadius: '6px',
mb: 1,
})}
>
<InputBase
sx={{ flex: 1, overflow: 'show' }}
placeholder="Paste ethereum address"
fullWidth
autoFocus
value={inputMockWalletAddress}
onChange={(e) => {
setInputMockWalletAddress(e.target.value);
}}
inputProps={{
'aria-label': 'amount input',
style: {
padding: 0,
},
}}
/>
</Box>
<Button
variant="outlined"
sx={{
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
mb: '8px',
}}
size="large"
fullWidth
disabled={!utils.isAddress(inputMockWalletAddress)}
onClick={() => handleWatchAddress(inputMockWalletAddress)}
>
Watch address
</Button>
{validAddressError && (
<Typography variant="helperText" color="error.main">
<Trans>Please enter a valid wallet address.</Trans>
</Typography>
)}
<Typography variant="description" sx={{ mt: '22px', mb: '30px', alignSelf: 'center' }}>
<Trans>
Need help connecting a wallet?{' '}
Expand Down
14 changes: 14 additions & 0 deletions src/components/infoTooltips/WatchOnlyModeTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Trans } from '@lingui/macro';

import { TextWithTooltip, TextWithTooltipProps } from '../TextWithTooltip';

export const WatchOnlyModeTooltip = ({ ...rest }: TextWithTooltipProps) => {
return (
<TextWithTooltip {...rest}>
<Trans>
Watch-only mode allows to see address positions in Aave, but you won&apos;t be able to
perform transactions.
</Trans>
</TextWithTooltip>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ClaimRewardsModalContent = () => {
const { gasLimit, mainTxState: claimRewardsTxState, txError } = useModalContext();
const { user, reserves } = useAppDataContext();
const { currentChainId, currentMarketData, currentMarket } = useProtocolDataContext();
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const [claimableUsd, setClaimableUsd] = useState('0');
const [selectedRewardSymbol, setSelectedRewardSymbol] = useState<string>('all');
const [rewards, setRewards] = useState<Reward[]>([]);
Expand Down Expand Up @@ -140,7 +140,7 @@ export const ClaimRewardsModalContent = () => {
return (
<>
<TxModalTitle title="Claim rewards" />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={currentChainId} />
)}

Expand Down
4 changes: 2 additions & 2 deletions src/components/transactions/Emode/EmodeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const EmodeModalContent = ({ mode }: EmodeModalContentProps) => {
userReserves,
} = useAppDataContext();
const { currentChainId } = useProtocolDataContext();
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const currentTimestamp = useCurrentTimestamp(1);
const { gasLimit, mainTxState: emodeTxState, txError } = useModalContext();

Expand Down Expand Up @@ -178,7 +178,7 @@ export const EmodeModalContent = ({ mode }: EmodeModalContentProps) => {
return (
<>
<TxModalTitle title={`${mode} E-Mode`} />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={currentChainId} />
)}

Expand Down
4 changes: 2 additions & 2 deletions src/components/transactions/FlowCommons/ModalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const ModalWrapper: React.FC<{
requiredPermission,
keepWrappedSymbol,
}) => {
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const { walletBalances } = useWalletBalances();
const {
currentChainId: marketChainId,
Expand Down Expand Up @@ -95,7 +95,7 @@ export const ModalWrapper: React.FC<{
{!mainTxState.success && (
<TxModalTitle title={title} symbol={hideTitleSymbol ? undefined : symbol} />
)}
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning
networkName={getNetworkConfig(requiredChainId).name}
chainId={requiredChainId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export enum ErrorType {
}

export const GovDelegationModalContent = () => {
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const {
daveTokens: { aave, stkAave },
} = useAaveTokensProviderContext();
Expand Down Expand Up @@ -101,7 +101,7 @@ export const GovDelegationModalContent = () => {
return (
<>
<TxModalTitle title="Delegate your power" />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={govChain} />
)}
<Typography variant="description">
Expand Down
4 changes: 2 additions & 2 deletions src/components/transactions/GovVote/GovVoteModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const GovVoteModalContent = ({
support,
power: votingPower,
}: GovVoteModalContentProps) => {
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const { gasLimit, mainTxState: txState, txError } = useModalContext();
const { currentNetworkConfig, currentChainId } = useProtocolDataContext();

Expand Down Expand Up @@ -78,7 +78,7 @@ export const GovVoteModalContent = ({
return (
<>
<TxModalTitle title="Governance vote" />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={govChain} />
)}
{blockingError !== undefined && (
Expand Down
4 changes: 2 additions & 2 deletions src/components/transactions/Stake/StakeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type StakingType = 'aave' | 'bpt';
export const StakeModalContent = ({ stakeAssetName, icon }: StakeProps) => {
const data = useStakeData();
const stakeData = data.stakeGeneralResult?.stakeGeneralUIData[stakeAssetName as StakingType];
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const { gasLimit, mainTxState: txState, txError } = useModalContext();
const { currentNetworkConfig, currentChainId } = useProtocolDataContext();

Expand Down Expand Up @@ -97,7 +97,7 @@ export const StakeModalContent = ({ stakeAssetName, icon }: StakeProps) => {
return (
<>
<TxModalTitle title="Stake" symbol={icon} />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={stakingChain} />
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type StakingType = 'aave' | 'bpt';

export const StakeCooldownModalContent = ({ stakeAssetName }: StakeCooldownProps) => {
const { stakeUserResult, stakeGeneralResult } = useStakeData();
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const { gasLimit, mainTxState: txState, txError } = useModalContext();
const { currentNetworkConfig, currentChainId } = useProtocolDataContext();

Expand Down Expand Up @@ -108,7 +108,7 @@ export const StakeCooldownModalContent = ({ stakeAssetName }: StakeCooldownProps
return (
<>
<TxModalTitle title="Cooldown to unstake" />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={stakingChain} />
)}
<Typography variant="description" sx={{ mb: 6 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type StakingType = 'aave' | 'bpt';
export const StakeRewardClaimModalContent = ({ stakeAssetName }: StakeRewardClaimProps) => {
const data = useStakeData();
const stakeData = data.stakeGeneralResult?.stakeGeneralUIData[stakeAssetName as StakingType];
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const { gasLimit, mainTxState: txState, txError } = useModalContext();
const { currentNetworkConfig, currentChainId } = useProtocolDataContext();

Expand Down Expand Up @@ -89,7 +89,7 @@ export const StakeRewardClaimModalContent = ({ stakeAssetName }: StakeRewardClai
return (
<>
<TxModalTitle title="Claim" symbol={rewardsSymbol} />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={stakingChain} />
)}
{blockingError !== undefined && (
Expand Down
15 changes: 11 additions & 4 deletions src/components/transactions/TxActionsWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Trans } from '@lingui/macro';
import { Box, BoxProps, Button, CircularProgress } from '@mui/material';
import { Box, BoxProps, Button, CircularProgress, Typography } from '@mui/material';
import isEmpty from 'lodash/isEmpty';
import { ReactNode } from 'react';
import { TxStateType, useModalContext } from 'src/hooks/useModal';
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
import { TxAction } from 'src/ui-config/errorMapping';

import { LeftHelperText } from './FlowCommons/LeftHelperText';
Expand Down Expand Up @@ -42,6 +43,7 @@ export const TxActionsWrapper = ({
...rest
}: TxActionsWrapperProps) => {
const { txError, retryWithApproval } = useModalContext();
const { mockAddress } = useWeb3Context();

const hasApprovalError =
requiresApproval && txError && txError.txAction === TxAction.APPROVAL && txError.actionBlocked;
Expand Down Expand Up @@ -87,14 +89,14 @@ export const TxActionsWrapper = ({

return (
<Box sx={{ display: 'flex', flexDirection: 'column', mt: 12, ...sx }} {...rest}>
{requiresApproval && (
{requiresApproval && !mockAddress && (
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 3 }}>
<LeftHelperText amount={amount} approvalHash={approvalTxState?.txHash} />
<RightHelperText approvalHash={approvalTxState?.txHash} />
</Box>
)}

{approvalParams && (
{approvalParams && !mockAddress && (
<Button
variant="contained"
disabled={approvalParams.disabled || blocked}
Expand All @@ -112,7 +114,7 @@ export const TxActionsWrapper = ({

<Button
variant="contained"
disabled={disabled || blocked}
disabled={disabled || blocked || mockAddress !== undefined}
onClick={handleClick}
size="large"
sx={{ minHeight: '44px', ...(approvalParams ? { mt: 2 } : {}) }}
Expand All @@ -121,6 +123,11 @@ export const TxActionsWrapper = ({
{loading && <CircularProgress color="inherit" size="16px" sx={{ mr: 2 }} />}
{content}
</Button>
{mockAddress && (
<Typography variant="helperText" sx={{ color: 'warning.main', textAlign: 'center', mt: 2 }}>
<Trans>Watch-only mode. Connect to a wallet to perform transactions.</Trans>
</Typography>
)}
</Box>
);
};
4 changes: 2 additions & 2 deletions src/components/transactions/UnStake/UnStakeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type StakingType = 'aave' | 'bpt';
export const UnStakeModalContent = ({ stakeAssetName, icon }: UnStakeProps) => {
const data = useStakeData();
const stakeData = data.stakeGeneralResult?.stakeGeneralUIData[stakeAssetName as StakingType];
const { chainId: connectedChainId } = useWeb3Context();
const { chainId: connectedChainId, mockAddress } = useWeb3Context();
const { gasLimit, mainTxState: txState, txError } = useModalContext();
const { currentNetworkConfig, currentChainId } = useProtocolDataContext();

Expand Down Expand Up @@ -97,7 +97,7 @@ export const UnStakeModalContent = ({ stakeAssetName, icon }: UnStakeProps) => {
return (
<>
<TxModalTitle title="Unstake" symbol={icon} />
{isWrongNetwork && (
{isWrongNetwork && !mockAddress && (
<ChangeNetworkWarning networkName={networkConfig.name} chainId={stakingChain} />
)}
<AssetInput
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useWalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export const WalletModalContext = createContext<WalletModalContextType>(
);

export const WalletModalContextProvider: React.FC = ({ children }) => {
const { connected } = useWeb3Context();
const { connected, mockAddress } = useWeb3Context();

const [isWalletModalOpen, setWalletModalOpen] = useState(false);

useEffect(() => {
if (connected) {
if (connected || mockAddress) {
setWalletModalOpen(false);
}
}, [connected]);
}, [connected, mockAddress]);

return (
<WalletModalContext.Provider
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function AppHeader() {
top: 0,
transition: theme.transitions.create('top'),
zIndex: theme.zIndex.appBar,
bgcolor: 'background.header',
bgcolor: '#1B2030',
Copy link
Contributor

@drewcook drewcook Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatthewCYLau - Instead of us updating this for this singular spot, I believe we need to update the background.header value in theme.tsx instead.

@iamanastasia - Do these color updates need to get applied to several areas also? Because updating out theme is the right answer to keep things consistent and easy to scale. I think you'd need to vet what gets affected design-wise with this.

padding: {
xs: mobileMenuOpen || walletWidgetOpen ? '8px 20px' : '8px 8px 8px 20px',
xsm: '8px 20px',
Expand Down
Loading