Skip to content
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
12 changes: 8 additions & 4 deletions cypress/e2e/2-settings/wallet-connect.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ export const closeModal = (selector: string) => {
cy.get(selector).click();
};

const walletButtonlocator = '#wallet-button';

describe('Manipulation on the wallet connect', () => {
describe('CASE1: Disconnect and connect wallet using Wallet connect option', () => {
configEnvWithTenderlyMainnetFork({});
const walletButton = '#wallet-button';

it('step1:Disconnect wallet', () => {
cy.wait(1000);
cy.get(walletButton).click();
cy.wait(6000);
cy.get(walletButtonlocator).click();
cy.wait(3000);
cy.contains('Disconnect').click();
cy.contains('Please, connect your wallet').should('be.visible');
});

it('step2:Connect wallet using wallet connect', () => {
cy.get(walletButton).click();
cy.get(walletButtonlocator).click();
optionOnConnectionModal('WalletConnect');
checkElementsOnModal(
'#walletconnect-qrcode-text',
Expand All @@ -39,6 +40,9 @@ describe('Manipulation on the wallet connect', () => {

describe('CASE2:Connect and disconnect wallet over Coinbase', () => {
it('step1:Connect wallet over Coinbase', () => {
cy.wait(1000);
cy.get(walletButtonlocator).click();
cy.wait(3000);
optionOnConnectionModal('Coinbase');
checkElementsOnModal('.-cbwsdk-extension-dialog-box', 'Try the Coinbase Wallet extension');
closeModal('.-cbwsdk-extension-dialog-box-cancel');
Expand Down
5 changes: 3 additions & 2 deletions src/components/AddressBlocked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
import { AddressBlockedModal } from './AddressBlockedModal';

export const AddressBlocked = ({ children }: { children: ReactNode }) => {
const { currentAccount, disconnectWallet } = useWeb3Context();
const { isAllowed } = useAddressAllowed(currentAccount);
const { currentAccount, disconnectWallet, watchModeOnly } = useWeb3Context();
const screenAddress = watchModeOnly ? '' : currentAccount;
const { isAllowed } = useAddressAllowed(screenAddress);

if (!isAllowed) {
return (
Expand Down
13 changes: 11 additions & 2 deletions src/libs/web3-data-provider/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type Web3Data = {
switchNetworkError: Error | undefined;
setSwitchNetworkError: (err: Error | undefined) => void;
watchModeOnlyAddress: string | undefined;
watchModeOnly: boolean;
};

export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ children }) => {
Expand All @@ -68,6 +69,7 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil
const [deactivated, setDeactivated] = useState(false);
const [triedGnosisSafe, setTriedGnosisSafe] = useState(false);
const [triedCoinbase, setTriedCoinbase] = useState(false);
const [watchModeOnly, setWatchModeOnly] = useState(false);
const [triedLedger, setTriedLedger] = useState(false);
const [switchNetworkError, setSwitchNetworkError] = useState<Error>();
const setAccount = useRootStore((store) => store.setAccount);
Expand Down Expand Up @@ -128,6 +130,13 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil
try {
const connector: AbstractConnector = getWallet(wallet, chainId);

if (connector instanceof WatchModeOnlyConnector) {
setWatchModeOnly(true);
} else {
setAccount('');
setWatchModeOnly(false);
}

if (connector instanceof WalletConnectConnector) {
connector.walletConnectProvider = undefined;
}
Expand Down Expand Up @@ -432,8 +441,8 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil
error,
switchNetworkError,
setSwitchNetworkError,
watchModeOnlyAddress:
connector instanceof WatchModeOnlyConnector ? account?.toLowerCase() : undefined,
watchModeOnlyAddress: watchModeOnly ? account?.toLowerCase() : undefined,
watchModeOnly,
},
}}
>
Expand Down