Skip to content

Commit

Permalink
Removing console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed May 12, 2023
1 parent 50887b0 commit 2fc11c6
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/components/new-modal/modals/SwitchChainModal.tsx
Expand Up @@ -6,7 +6,7 @@ import React, { useCallback, useMemo } from 'react';

const SwitchChainModal = () => {
const { isLoading, switchNetwork, forceNetwork } = useMasa();
console.log({ isLoading, switchNetwork, forceNetwork });

const networkData: Network | undefined = useMemo(() => {
if (forceNetwork) {
return SupportedNetworks[forceNetwork];
Expand Down
2 changes: 0 additions & 2 deletions src/provider/hooks.ts
Expand Up @@ -120,9 +120,7 @@ export const useLogout = (
try {
onLogoutStart?.();
await masa?.session.sessionLogout();
console.log('before query');
await invalidateAllQueries({ masa, signer, walletAddress });
console.log('after query');
await disconnectAsync();
return true;
} catch (error: unknown) {
Expand Down
1 change: 0 additions & 1 deletion src/provider/masa-context-provider.tsx
Expand Up @@ -116,7 +116,6 @@ export const MasaContextProvider = ({
reloadIdentity,
} = useIdentity(masaInstance, walletAddress);

// console.log({ isDisconnected, loggedIn, isLoggingOut, identity });
// soul names
const { soulnames, isSoulnamesLoading, reloadSoulnames } = useSoulnames(
masaInstance,
Expand Down
1 change: 0 additions & 1 deletion src/provider/modules/modal-provider.tsx
Expand Up @@ -57,7 +57,6 @@ export const ModalManagerProvider = ({ children }: { children: ReactNode }) => {
wrapperProps?: WrapperModalProps;
contentProps: any;
}) => {
console.log('abo');
setTitle(title);
setCurrentModal(name);
setModalContentProps(contentProps);
Expand Down
6 changes: 0 additions & 6 deletions src/provider/modules/network/network.ts
Expand Up @@ -79,12 +79,6 @@ export const useNetwork = ({
const switchNetwork = useCallback(
async (networkName: NetworkName) => {
const network = SupportedNetworks[networkName];

console.log({
network,

chainId: utils.hexValue(network?.chainId ?? 1),
});
try {
if (typeof window !== 'undefined' && network) {
await window?.ethereum?.request({
Expand Down
18 changes: 0 additions & 18 deletions src/provider/modules/session/session.ts
Expand Up @@ -2,7 +2,6 @@ import { useCallback, useEffect, useMemo } from 'react';
import { useQuery } from 'react-query';
import { queryClient } from '../../masa-query-client';
import { ISession, Masa } from '@masa-finance/masa-sdk';
// import { useDisconnect } from 'wagmi';
import { useAsync } from 'react-use';

export const getSessionQueryKey = ({
Expand Down Expand Up @@ -132,13 +131,11 @@ export const useSession = (

const handleLogout = useCallback(
async (logoutCallback?: () => void): Promise<void> => {
console.log('logging outtt!! in session.ts');
if (!isLoggedIn) {
return;
}

try {
// await disconnectAsync();
await masa?.session.sessionLogout();
} finally {
await clearSession();
Expand All @@ -157,25 +154,10 @@ export const useSession = (
}, [masa, clearSession]);

useEffect(() => {
// reloadSession();
reloadSessionData();
}, [walletAddress, reloadSession, reloadSessionData]);
// useEffect(() => {
// (async () => {
// console.log({ sessionData });
// if (
// isLoggedIn &&
// sessionData &&
// sessionData.user.address !== walletAddress
// ) {
// console.error('Session mismatch detected, logging out!');
// void handleLogout();
// }
// })();
// }, [sessionData, walletAddress, handleLogout, isLoggedIn]);

useAsync(async () => {
console.log({ sessionData });
if (
isLoggedIn &&
sessionData &&
Expand Down
35 changes: 0 additions & 35 deletions src/provider/modules/wagmi/use-wagmi.tsx
@@ -1,6 +1,5 @@
import {
Chain,
// ConnectorData,
useAccount,
useDisconnect,
useNetwork,
Expand All @@ -23,7 +22,6 @@ export const useWagmi = ({
const {
isLoading: isLoadingNetwork,
status,
// pendingChainId,
} = useSwitchNetwork();

const {
Expand All @@ -37,39 +35,7 @@ export const useWagmi = ({
});
const { disconnect } = useDisconnect();

// const { connector: activeConnector } = useAccount();

// // * detects if we have a new account or chain
// useEffect(() => {
// const handleConnectorUpdate = ({ account, chain }: ConnectorData) => {
// if (account) {
// console.log('new account', account);
// // TODO: set variables that are needed when account is changed
// } else if (chain) {
// console.log('new chain', chain);
// }
// };

// if (activeConnector) {
// activeConnector.on('change', handleConnectorUpdate);
// }

// return () => {
// activeConnector?.off('change', handleConnectorUpdate);
// };
// }, [activeConnector]);

useEffect(() => {
console.log('ISLOADING NETWORK', {
...{
isLoadingNetwork,
status,
isReconnecting,
provider,
isSignerLoading,
chain: chain?.network,
},
});
if (isReconnecting) {
return;
}
Expand All @@ -78,7 +44,6 @@ export const useWagmi = ({
}

setSigner(signer as Signer);
// console.log('setSigner wagmi', { setSigner, signer });
}, [
setSigner,
chain,
Expand Down
33 changes: 14 additions & 19 deletions src/provider/use-account-state.ts
Expand Up @@ -59,7 +59,6 @@ export const useAccountState = ({
useAsync(async () => {
const handleConnectorUpdate = async ({ account }: ConnectorData) => {
if (account) {
console.log('new account', account);
setAccountAddress(account);
await invalidateAllQueries({ masa, signer, walletAddress });
// reloadIdentity?.();
Expand Down Expand Up @@ -88,7 +87,6 @@ export const useAccountState = ({
// * if we are initializing
// * TODO: remove this logic once proper walletAddress scoping is in place
if (walletAddress && !accountAddress && !isDisconnected) {
console.log('setting account address to wallet address', walletAddress);
setAccountAddress(walletAddress);
await invalidateAllQueries({ masa, signer, walletAddress });
}
Expand Down Expand Up @@ -139,26 +137,23 @@ export const useAccountState = ({
}
}, [hasWalletAddress, accountAddress, wagmiAddress, reloadWallet]);

console.log('use-account-state', {
accountAddress,
signer,
isConnected,
isConnecting,
isDisconnected,
if (masa?.config.verbose) {
console.log('use-account-state', {
accountAddress,
signer,
isConnected,
isConnecting,
isDisconnected,

hasLoggedOut,
isLoggingOut,
hasLoggedOut,
isLoggingOut,

hasWalletAddress,
hasAccountAddress,
walletAddress,
});
hasWalletAddress,
hasAccountAddress,
walletAddress,
});
}

// useAsync(async () => {
// if (isDisconnected) {
// await invalidateAllQueries({ masa, signer, walletAddress });
// }
// }, [isDisconnected, masa, signer, walletAddress]);
return {
accountAddress,
signer,
Expand Down
3 changes: 0 additions & 3 deletions src/provider/use-metamask.ts
Expand Up @@ -66,7 +66,6 @@ export const useMetamask = ({
const signer = getWeb3Provider()?.getSigner();

if (signer && accounts.length > 0 && setSigner) {
console.log('setsigner', connectMetamask);
setSigner(signer);
metamaskConnected = true;
localStorageSet<boolean>(metamaskStorageKey, true);
Expand Down Expand Up @@ -178,7 +177,6 @@ export const useMetamask = ({
// no accounts, disconnect metamask
await disconnectMetamask();
// drop provider
console.log('removing signer metamask', { setSigner });
setSigner?.();
}

Expand All @@ -193,7 +191,6 @@ export const useMetamask = ({
(window.ethereum as unknown as MetaMaskInpageProvider)?.on(
'chainChanged',
() => {
console.log('set signer use meta mask', { setSigner });
setSigner?.(getWeb3Provider()?.getSigner());
}
);
Expand Down
1 change: 0 additions & 1 deletion src/provider/use-rainbowkit.tsx
Expand Up @@ -30,7 +30,6 @@ export const useRainbowKit = () => {
useEffect(() => {
if (modalCallback && openAccountModal && openChainModal) {
// we open the original modal of useMasa now
console.log('calling modal callback');
modalCallback();
// setRainbowKitModalCallback(undefined);
}
Expand Down

0 comments on commit 2fc11c6

Please sign in to comment.