Skip to content

Commit

Permalink
fix: switch network only for argentx
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Nov 29, 2024
1 parent 4861997 commit 9403ba5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
6 changes: 3 additions & 3 deletions components/UI/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
getConnectorIcon,
getLastConnected,
getLastConnector,
isArgentWallet,
supportSwitchNetwork,
} from "@/utils/connectorWrapper";
import WalletConnect from "./walletConnect";
import ArrowDownIcon from "./iconsComponents/icons/arrowDownIcon";
Expand Down Expand Up @@ -147,7 +147,7 @@ const Navbar: FunctionComponent = () => {
}

const switchNetwork = async () => {
if (isArgentWallet(connector)) {
if (supportSwitchNetwork(connector)) {
const res = await switchChainAsync();
if (res) setIsWrongNetwork(false);
} else {
Expand Down Expand Up @@ -396,7 +396,7 @@ const Navbar: FunctionComponent = () => {
</p>
<div className="mt-5">
<Button onClick={() => switchNetwork()}>
{isArgentWallet(connector)
{supportSwitchNetwork(connector)
? `Switch to ${network}`
: "Disconnect"}
</Button>
Expand Down
9 changes: 2 additions & 7 deletions utils/connectorWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,8 @@ export const getLastConnected = (): Connector | null => {
return null;
};

export const isArgentWallet = (connector?: StarknetReactConnector) => {
return (
connector &&
(connector.id === "argentX" ||
connector.id === "argentMobile" ||
connector.id === "argentWebWallet")
);
export const supportSwitchNetwork = (connector?: StarknetReactConnector) => {
return connector && connector.id === "argentX";
};

const wallets = [
Expand Down

0 comments on commit 9403ba5

Please sign in to comment.