Skip to content

Commit

Permalink
fix reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
sonln99 committed Jun 21, 2024
1 parent 62ffbad commit dd800cf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/app/get-aura/deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
useBalance,
useWaitForTransactionReceipt,
BaseError,
useReconnect,
} from "wagmi";
import TableHistory from "./table";
import { stringToHex, parseEther, parseUnits, formatUnits } from "viem";
Expand Down Expand Up @@ -131,6 +132,14 @@ function Deposit() {
getActivityHistory(address?.toLowerCase() || "");
}
}, [address]);
const { reconnect } = useReconnect();

useEffect(() => {
if (!isConnected) {
reconnect();
console.log('-----------reconnect')
}
}, [isConnected]);

if (isDisconnected) {
redirect("/get-aura");
Expand Down
16 changes: 15 additions & 1 deletion src/app/get-aura/wallet-connect.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { ConnectButton } from "@rainbow-me/rainbowkit";
import { useAccount, useAccountEffect, useDisconnect } from "wagmi";
import {
useAccount,
useAccountEffect,
useDisconnect,
useReconnect,
} from "wagmi";
import copyLogo from "@/assets/images/img_copy_logo.svg";
import Image from "next/image";
import { Tooltip } from "react-tooltip";
import "./style.css";
import { toast } from "react-toastify";
import { useEffect } from "react";
function WalletConnectEVM() {
const { isConnected, address } = useAccount();
const { disconnect } = useDisconnect();
Expand All @@ -18,6 +24,14 @@ function WalletConnectEVM() {
toastDisconnect();
},
});
const { reconnect } = useReconnect();
useEffect(() => {
if (!isConnected) {
reconnect();
console.log("-----------reconnect");
}
}, [isConnected]);

return (
<div className="mb-[80px]">
<div className="main-container">
Expand Down

0 comments on commit dd800cf

Please sign in to comment.