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

test #818

Draft
wants to merge 4 commits into
base: staging
Choose a base branch
from
Draft

test #818

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
24 changes: 12 additions & 12 deletions packages/widget/src/hooks/useCreateEvmWallets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { useCallback } from "react";
import { createPublicClient, http } from "viem";
import { sei } from "viem/chains";
import { useAccount, useConnect, useConnectors } from "wagmi";
import { useAccount, useConnect, useConnectors, useSwitchChain } from "wagmi";
import { ChainType } from "@skip-go/client";
import { walletConnectLogo } from "@/constants/wagmi";
import { callbacksAtom } from "@/state/callbacks";
Expand All @@ -26,6 +26,7 @@

const { connector: currentEvmConnector, isConnected: isEvmConnected, chainId } = useAccount();
const { connectAsync } = useConnect();
const { switchChain } = useSwitchChain();

Check failure on line 29 in packages/widget/src/hooks/useCreateEvmWallets.tsx

View workflow job for this annotation

GitHub Actions / eslint

'switchChain' is assigned a value but never used. Allowed unused vars must match /^_/u
const connectors = useConnectors();
const currentConnector = connectors.find((connector) => connector.id === currentEvmConnector?.id);

Expand All @@ -48,22 +49,21 @@
const isWalletConnect = connector.id === "walletConnect";

const connectWallet = async ({ chainIdToConnect = "1" }: { chainIdToConnect?: string }) => {
const walletConnectedButNeedToSwitchChain =
isEvmConnected &&
chainId !== Number(chainIdToConnect) &&
connector.id === currentEvmConnector?.id;
// const needToSwitchChain =
// isEvmConnected &&
// chainId !== Number(chainIdToConnect) &&
// connector.id === currentEvmConnector?.id;

try {
if (isEvmConnected && connector.id !== currentEvmConnector?.id) {
await currentConnector?.disconnect();
}
if (walletConnectedButNeedToSwitchChain) {
await connector?.switchChain?.({
chainId: Number(chainIdToConnect),
});
} else {
await connectAsync({ connector, chainId: Number(chainIdToConnect) });
}
console.log(connector, chainIdToConnect);

Check failure on line 61 in packages/widget/src/hooks/useCreateEvmWallets.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
await connector.connect({ chainId: Number(chainIdToConnect) });

// switchChain?.({
// chainId: Number(chainIdToConnect),
// });

if (sourceAsset === undefined) {
const chain = chains?.find((x) => x.chainID === "1");
Expand Down Expand Up @@ -166,7 +166,7 @@
}
return wallets;
},
[

Check warning on line 169 in packages/widget/src/hooks/useCreateEvmWallets.tsx

View workflow job for this annotation

GitHub Actions / eslint

React Hook useCallback has unnecessary dependencies: 'chainId' and 'connectAsync'. Either exclude them or remove the dependency array
connectors,
currentEvmConnector?.id,
isEvmConnected,
Expand Down
Loading