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

fix: account in readonly [skip cypress] #2304

Merged
merged 2 commits into from
Jan 6, 2025
Merged
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
15 changes: 1 addition & 14 deletions src/libs/web3-data-provider/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil
const { switchChainAsync } = useSwitchChain();
const { watchAssetAsync } = useWatchAsset();
const { chainId, address } = useAccount();
// const { disconnect } = useDisconnect();
const { connect, connectors } = useConnect();

const [readOnlyModeAddress, setReadOnlyModeAddress] = useState<string | undefined>();
Expand All @@ -57,22 +56,10 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil
currentAccount = readOnlyModeAddress;
}

// console.log('isConnecting', isConnecting);
// console.log('isConnected', isConnected);

useEffect(() => {
if (didInit) {
return;
}
// if (didInit) {
// // If user connects a wallet after the app is loaded, then we need to reset the readOnlyModeAddress
// if (isConnected && readOnlyMode) {
// localStorage.removeItem('readOnlyModeAddress');
// setReadOnlyModeAddress(undefined);
// }

// return;
// }

// If the app loads in readOnlyMode, then we disconnect the wallet if it auto connected
const storedReadOnlyAddress = localStorage.getItem('readOnlyModeAddress');
Expand Down Expand Up @@ -188,7 +175,7 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil

useEffect(() => {
if (readOnlyModeAddress) {
setAccount(readOnlyModeAddress);
setAccount(readOnlyModeAddress.toLowerCase());
}
}, [readOnlyModeAddress, setAccount]);

Expand Down
Loading