Skip to content

Commit

Permalink
correct warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Feb 13, 2023
1 parent df5bb73 commit 5fb2068
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 36 deletions.
12 changes: 1 addition & 11 deletions src/components/masa-interface/masa-interface.tsx
Expand Up @@ -30,7 +30,6 @@ export const MasaInterface = ({
isModalOpen,
setModalOpen,
isConnected,
loading,
identity,
loggedIn,
closeModal,
Expand All @@ -52,16 +51,7 @@ export const MasaInterface = ({
if (isConnected && loggedIn) return 'connectedState';

return 'connector';
}, [
loading,
isConnected,
identity,
loggedIn,
scope,
creditScores,
network,
chain,
]);
}, [isConnected, identity, loggedIn, scope, creditScores, network, chain]);

return (
<>
Expand Down
31 changes: 14 additions & 17 deletions src/provider/masa-context-provider.tsx
Expand Up @@ -175,23 +175,20 @@ export const MasaContextProvider = ({
chain,
]);

const addNetwork = useCallback(
async (networkDetails: Network) => {
try {
if (typeof window !== 'undefined' && networkDetails) {
await window?.ethereum?.request({
method: 'wallet_addEthereumChain',
params: [networkDetails],
});
}
} catch (error) {
console.error(
`error ocuured while adding new chain with chainId:${networkDetails?.chainId}`
);
const addNetwork = useCallback(async (networkDetails: Network) => {
try {
if (typeof window !== 'undefined' && networkDetails) {
await window?.ethereum?.request({
method: 'wallet_addEthereumChain',
params: [networkDetails],
});
}
},
[provider]
);
} catch (error) {
console.error(
`error ocuured while adding new chain with chainId:${networkDetails?.chainId}`
);
}
}, []);

const switchNetwork = useCallback(
async (chainId: number) => {
Expand All @@ -210,7 +207,7 @@ export const MasaContextProvider = ({
}
}
},
[provider]
[addNetwork]
);

const context = {
Expand Down
4 changes: 2 additions & 2 deletions src/provider/masa-context.tsx
Expand Up @@ -59,10 +59,10 @@ export interface MasaShape {
handleCreateGreen?: (
phoneNumber: string,
code: string
) => Promise<GenerateGreenResult | undefined>;
) => Promise<VerifyGreenResult | undefined>;
handleGenerateGreen?: (
phoneNumber: string
) => Promise<VerifyGreenResult | undefined>;
) => Promise<GenerateGreenResult | undefined>;
chain?: null | ethers.providers.Network;
switchNetwork?: (chainId: number) => void;
SupportedNetworks?: { [index: number]: Network };
Expand Down
2 changes: 1 addition & 1 deletion src/provider/modules/credit-scores/credit-scores.ts
Expand Up @@ -47,7 +47,7 @@ export const useCreditScores = (
await queryClient.invalidateQueries(queryKey);

return response?.success;
}, [masa, walletAddress, queryKey]);
}, [masa, queryKey]);

return {
creditScores,
Expand Down
4 changes: 2 additions & 2 deletions src/provider/modules/green/green.ts
Expand Up @@ -39,7 +39,7 @@ export const useGreen = (
} => {
const queryKey: string = useMemo(() => {
return `green-${walletAddress}-${masa?.config.network}`;
}, [walletAddress, masa?.config.network]);
}, [walletAddress, masa]);

const {
data: greens,
Expand All @@ -61,7 +61,7 @@ export const useGreen = (

return response;
},
[masa, walletAddress]
[masa, queryKey]
);

const handleGenerateGreen = useCallback(
Expand Down
4 changes: 2 additions & 2 deletions src/provider/modules/session/session.ts
Expand Up @@ -39,7 +39,7 @@ export const useSession = (
await queryClient.invalidateQueries(queryKey);
await queryClient.refetchQueries();
}
}, [masa, walletAddress, queryKey]);
}, [masa, queryKey]);

const logout = useCallback(
async (callback?: () => void) => {
Expand All @@ -51,7 +51,7 @@ export const useSession = (
callback();
}
},
[masa, walletAddress, queryKey]
[masa, queryKey]
);

return { loggedIn, login, logout, status, isLoading, error };
Expand Down
4 changes: 3 additions & 1 deletion src/provider/use-metamask.ts
Expand Up @@ -13,7 +13,9 @@ export const useMetamask = ({
const provider = useMemo(() => {
if (typeof window !== 'undefined') {
if (typeof window?.ethereum !== 'undefined') {
return new ethers.providers.Web3Provider(window?.ethereum as any);
return new ethers.providers.Web3Provider(
window?.ethereum as unknown as ethers.providers.ExternalProvider
);
} else {
return null;
}
Expand Down

0 comments on commit 5fb2068

Please sign in to comment.