diff --git a/package-lock.json b/package-lock.json index 15879236..5873aac4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,8 +43,8 @@ "react-redux": "^8.1.3", "redis": "^4.6.11", "redis-om": "^0.4.3", - "viem": "^1.19.11", - "wagmi": "^1.4.10" + "viem": "^1.20.0", + "wagmi": "^1.4.12" }, "devDependencies": { "@etherisc/gif-interface": "2.0.0-rc.1-0", @@ -2548,11 +2548,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@ledgerhq/connect-kit-loader": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.1.2.tgz", - "integrity": "sha512-mscwGroSJQrCTjtNGBu+18FQbZYA4+q6Tyx6K7CXHl6AwgZKbWfZYdgP2F+fyZcRUdGRsMX8QtvU61VcGGtO1A==" - }, "node_modules/@lit-labs/ssr-dom-shim": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.1.1.tgz", @@ -3641,23 +3636,14 @@ "dev": true }, "node_modules/@safe-global/safe-apps-provider": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/@safe-global/safe-apps-provider/-/safe-apps-provider-0.17.1.tgz", - "integrity": "sha512-lYfRqrbbK1aKU1/UGkYWc/X7PgySYcumXKc5FB2uuwAs2Ghj8uETuW5BrwPqyjBknRxutFbTv+gth/JzjxAhdQ==", + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@safe-global/safe-apps-provider/-/safe-apps-provider-0.18.1.tgz", + "integrity": "sha512-V4a05A3EgJcriqtDoJklDz1BOinWhC6P0hjUSxshA4KOZM7rGPCTto/usXs09zr1vvL28evl/NldSTv97j2bmg==", "dependencies": { - "@safe-global/safe-apps-sdk": "8.0.0", + "@safe-global/safe-apps-sdk": "^8.1.0", "events": "^3.3.0" } }, - "node_modules/@safe-global/safe-apps-provider/node_modules/@safe-global/safe-apps-sdk": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@safe-global/safe-apps-sdk/-/safe-apps-sdk-8.0.0.tgz", - "integrity": "sha512-gYw0ki/EAuV1oSyMxpqandHjnthZjYYy+YWpTAzf8BqfXM3ItcZLpjxfg+3+mXW8HIO+3jw6T9iiqEXsqHaMMw==", - "dependencies": { - "@safe-global/safe-gateway-typescript-sdk": "^3.5.3", - "viem": "^1.0.0" - } - }, "node_modules/@safe-global/safe-apps-sdk": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/@safe-global/safe-apps-sdk/-/safe-apps-sdk-8.1.0.tgz", @@ -4790,9 +4776,9 @@ "dev": true }, "node_modules/@wagmi/connectors": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-3.1.8.tgz", - "integrity": "sha512-J6m8xWFw/Qb4V6VeERazEgfXPztx7wDWCfmUSrfSM54SSjdaFprAOZlcAMqBtibqH8HgnPvbdFA0DEOHbeX2ag==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-3.1.10.tgz", + "integrity": "sha512-ZLJC1QaeiZarkF07Cr9mOlVjPO1Lf5TBx+JKBms2y5fUIXlKrxCfQgO/gDCureboI+Us2X3IRI659+XacSGpbA==", "funding": [ { "type": "gitcoin", @@ -4805,9 +4791,8 @@ ], "dependencies": { "@coinbase/wallet-sdk": "^3.6.6", - "@ledgerhq/connect-kit-loader": "^1.1.0", - "@safe-global/safe-apps-provider": "^0.17.1", - "@safe-global/safe-apps-sdk": "^8.0.0", + "@safe-global/safe-apps-provider": "^0.18.1", + "@safe-global/safe-apps-sdk": "^8.1.0", "@walletconnect/ethereum-provider": "2.10.6", "@walletconnect/legacy-provider": "^2.0.0", "@walletconnect/modal": "2.6.2", @@ -4826,9 +4811,9 @@ } }, "node_modules/@wagmi/core": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-1.4.10.tgz", - "integrity": "sha512-XJ5iSWZKOZSgQP3LFn/QHJqLGoX53SiBKc0/6s7KkVc68VmFenrZymNRg3fSwBsINlZgRVWpSj2lAVsl8IjSgw==", + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-1.4.12.tgz", + "integrity": "sha512-bLcYmmGgjtl3jAGo8X3Sm6oUwsdjbVxFMu9SWnwHdE4S9JdYeWM57dEhQgq8SYul2yQ7yY2/gimBf1Or0Ky3dQ==", "funding": [ { "type": "gitcoin", @@ -4840,7 +4825,7 @@ } ], "dependencies": { - "@wagmi/connectors": "3.1.8", + "@wagmi/connectors": "3.1.10", "abitype": "0.8.7", "eventemitter3": "^4.0.7", "zustand": "^4.3.1" @@ -13598,9 +13583,9 @@ } }, "node_modules/rpc-websockets/node_modules/ws": { - "version": "8.15.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.15.0.tgz", - "integrity": "sha512-H/Z3H55mrcrgjFwI+5jKavgXvwQLtfPCUEp6pi35VhoB0pfcHnSoyuTzkBEZpzq49g1193CUEwIvmsjcotenYw==", + "version": "8.15.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.15.1.tgz", + "integrity": "sha512-W5OZiCjXEmk0yZ66ZN82beM5Sz7l7coYxpRkzS+p9PP+ToQry8szKh+61eNktr7EA9DOwvFGhfC605jDHbP6QQ==", "engines": { "node": ">=10.0.0" }, @@ -14779,11 +14764,11 @@ } }, "node_modules/untun": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/untun/-/untun-0.1.2.tgz", - "integrity": "sha512-wLAMWvxfqyTiBODA1lg3IXHQtjggYLeTK7RnSfqtOXixWJ3bAa2kK/HHmOOg19upteqO3muLvN6O/icbyQY33Q==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/untun/-/untun-0.1.3.tgz", + "integrity": "sha512-4luGP9LMYszMRZwsvyUd9MrxgEGZdZuZgpVQHEEX0lCYFESasVRvZd0EYpCkOIbJKHMuv0LskpXc/8Un+MJzEQ==", "dependencies": { - "citty": "^0.1.3", + "citty": "^0.1.5", "consola": "^3.2.3", "pathe": "^1.1.1" }, @@ -14949,9 +14934,9 @@ } }, "node_modules/viem": { - "version": "1.19.11", - "resolved": "https://registry.npmjs.org/viem/-/viem-1.19.11.tgz", - "integrity": "sha512-dbsXEWDBZkByuzJXAs/e01j7dpUJ5ICF5WcyntFwf8Y97n5vnC/91lAleSa6DA5V4WJvYZbhDpYeTctsMAQnhA==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/viem/-/viem-1.20.0.tgz", + "integrity": "sha512-yPjV9pJr10xi28C/9LEvs5zdZNEMiru3Kz7nufghVYABJAfeSkoZQXb6b23n7MscS7c55JO5nmUI3xKkd9g6Yg==", "funding": [ { "type": "github", @@ -15041,9 +15026,9 @@ } }, "node_modules/wagmi": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-1.4.10.tgz", - "integrity": "sha512-n37srrOLWZIHq0ROXj15bpCZEo8GBtABcPchPDneTz3QUpLGY+EeiXrBaFHWcjNiTBOgDHyLIuS4Q0Xtj/DiYQ==", + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-1.4.12.tgz", + "integrity": "sha512-QRxpjhdMlZmbYTfn9VQkQMKq+l3kwA1O7tF10vaykPrjbGX+IIlyn72ib9oqW9BfQO7n/Sf/mnVz1zbxRhGPWA==", "funding": [ { "type": "gitcoin", @@ -15058,7 +15043,7 @@ "@tanstack/query-sync-storage-persister": "^4.27.1", "@tanstack/react-query": "^4.28.0", "@tanstack/react-query-persist-client": "^4.28.0", - "@wagmi/core": "1.4.10", + "@wagmi/core": "1.4.12", "abitype": "0.8.7", "use-sync-external-store": "^1.2.0" }, @@ -17274,11 +17259,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "@ledgerhq/connect-kit-loader": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.1.2.tgz", - "integrity": "sha512-mscwGroSJQrCTjtNGBu+18FQbZYA4+q6Tyx6K7CXHl6AwgZKbWfZYdgP2F+fyZcRUdGRsMX8QtvU61VcGGtO1A==" - }, "@lit-labs/ssr-dom-shim": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.1.1.tgz", @@ -17903,23 +17883,12 @@ "dev": true }, "@safe-global/safe-apps-provider": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/@safe-global/safe-apps-provider/-/safe-apps-provider-0.17.1.tgz", - "integrity": "sha512-lYfRqrbbK1aKU1/UGkYWc/X7PgySYcumXKc5FB2uuwAs2Ghj8uETuW5BrwPqyjBknRxutFbTv+gth/JzjxAhdQ==", + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@safe-global/safe-apps-provider/-/safe-apps-provider-0.18.1.tgz", + "integrity": "sha512-V4a05A3EgJcriqtDoJklDz1BOinWhC6P0hjUSxshA4KOZM7rGPCTto/usXs09zr1vvL28evl/NldSTv97j2bmg==", "requires": { - "@safe-global/safe-apps-sdk": "8.0.0", + "@safe-global/safe-apps-sdk": "^8.1.0", "events": "^3.3.0" - }, - "dependencies": { - "@safe-global/safe-apps-sdk": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@safe-global/safe-apps-sdk/-/safe-apps-sdk-8.0.0.tgz", - "integrity": "sha512-gYw0ki/EAuV1oSyMxpqandHjnthZjYYy+YWpTAzf8BqfXM3ItcZLpjxfg+3+mXW8HIO+3jw6T9iiqEXsqHaMMw==", - "requires": { - "@safe-global/safe-gateway-typescript-sdk": "^3.5.3", - "viem": "^1.0.0" - } - } } }, "@safe-global/safe-apps-sdk": { @@ -18811,14 +18780,13 @@ "dev": true }, "@wagmi/connectors": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-3.1.8.tgz", - "integrity": "sha512-J6m8xWFw/Qb4V6VeERazEgfXPztx7wDWCfmUSrfSM54SSjdaFprAOZlcAMqBtibqH8HgnPvbdFA0DEOHbeX2ag==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-3.1.10.tgz", + "integrity": "sha512-ZLJC1QaeiZarkF07Cr9mOlVjPO1Lf5TBx+JKBms2y5fUIXlKrxCfQgO/gDCureboI+Us2X3IRI659+XacSGpbA==", "requires": { "@coinbase/wallet-sdk": "^3.6.6", - "@ledgerhq/connect-kit-loader": "^1.1.0", - "@safe-global/safe-apps-provider": "^0.17.1", - "@safe-global/safe-apps-sdk": "^8.0.0", + "@safe-global/safe-apps-provider": "^0.18.1", + "@safe-global/safe-apps-sdk": "^8.1.0", "@walletconnect/ethereum-provider": "2.10.6", "@walletconnect/legacy-provider": "^2.0.0", "@walletconnect/modal": "2.6.2", @@ -18828,11 +18796,11 @@ } }, "@wagmi/core": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-1.4.10.tgz", - "integrity": "sha512-XJ5iSWZKOZSgQP3LFn/QHJqLGoX53SiBKc0/6s7KkVc68VmFenrZymNRg3fSwBsINlZgRVWpSj2lAVsl8IjSgw==", + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-1.4.12.tgz", + "integrity": "sha512-bLcYmmGgjtl3jAGo8X3Sm6oUwsdjbVxFMu9SWnwHdE4S9JdYeWM57dEhQgq8SYul2yQ7yY2/gimBf1Or0Ky3dQ==", "requires": { - "@wagmi/connectors": "3.1.8", + "@wagmi/connectors": "3.1.10", "abitype": "0.8.7", "eventemitter3": "^4.0.7", "zustand": "^4.3.1" @@ -25346,9 +25314,9 @@ }, "dependencies": { "ws": { - "version": "8.15.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.15.0.tgz", - "integrity": "sha512-H/Z3H55mrcrgjFwI+5jKavgXvwQLtfPCUEp6pi35VhoB0pfcHnSoyuTzkBEZpzq49g1193CUEwIvmsjcotenYw==", + "version": "8.15.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.15.1.tgz", + "integrity": "sha512-W5OZiCjXEmk0yZ66ZN82beM5Sz7l7coYxpRkzS+p9PP+ToQry8szKh+61eNktr7EA9DOwvFGhfC605jDHbP6QQ==", "requires": {} } } @@ -26200,11 +26168,11 @@ } }, "untun": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/untun/-/untun-0.1.2.tgz", - "integrity": "sha512-wLAMWvxfqyTiBODA1lg3IXHQtjggYLeTK7RnSfqtOXixWJ3bAa2kK/HHmOOg19upteqO3muLvN6O/icbyQY33Q==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/untun/-/untun-0.1.3.tgz", + "integrity": "sha512-4luGP9LMYszMRZwsvyUd9MrxgEGZdZuZgpVQHEEX0lCYFESasVRvZd0EYpCkOIbJKHMuv0LskpXc/8Un+MJzEQ==", "requires": { - "citty": "^0.1.3", + "citty": "^0.1.5", "consola": "^3.2.3", "pathe": "^1.1.1" } @@ -26319,9 +26287,9 @@ } }, "viem": { - "version": "1.19.11", - "resolved": "https://registry.npmjs.org/viem/-/viem-1.19.11.tgz", - "integrity": "sha512-dbsXEWDBZkByuzJXAs/e01j7dpUJ5ICF5WcyntFwf8Y97n5vnC/91lAleSa6DA5V4WJvYZbhDpYeTctsMAQnhA==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/viem/-/viem-1.20.0.tgz", + "integrity": "sha512-yPjV9pJr10xi28C/9LEvs5zdZNEMiru3Kz7nufghVYABJAfeSkoZQXb6b23n7MscS7c55JO5nmUI3xKkd9g6Yg==", "requires": { "@adraffy/ens-normalize": "1.10.0", "@noble/curves": "1.2.0", @@ -26362,14 +26330,14 @@ } }, "wagmi": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-1.4.10.tgz", - "integrity": "sha512-n37srrOLWZIHq0ROXj15bpCZEo8GBtABcPchPDneTz3QUpLGY+EeiXrBaFHWcjNiTBOgDHyLIuS4Q0Xtj/DiYQ==", + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-1.4.12.tgz", + "integrity": "sha512-QRxpjhdMlZmbYTfn9VQkQMKq+l3kwA1O7tF10vaykPrjbGX+IIlyn72ib9oqW9BfQO7n/Sf/mnVz1zbxRhGPWA==", "requires": { "@tanstack/query-sync-storage-persister": "^4.27.1", "@tanstack/react-query": "^4.28.0", "@tanstack/react-query-persist-client": "^4.28.0", - "@wagmi/core": "1.4.10", + "@wagmi/core": "1.4.12", "abitype": "0.8.7", "use-sync-external-store": "^1.2.0" } diff --git a/package.json b/package.json index 4a3b8155..6617f47c 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "react-redux": "^8.1.3", "redis": "^4.6.11", "redis-om": "^0.4.3", - "viem": "^1.19.11", - "wagmi": "^1.4.10" + "viem": "^1.20.0", + "wagmi": "^1.4.12" }, "devDependencies": { "@etherisc/gif-interface": "2.0.0-rc.1-0", diff --git a/src/components/account/account.tsx b/src/components/account/account.tsx index 5c61d817..e310616c 100644 --- a/src/components/account/account.tsx +++ b/src/components/account/account.tsx @@ -21,7 +21,7 @@ export default function Account() { const signer = useSelector((state: RootState) => state.chain.signer); const { isConnected, isWalletConnect } = useSelector((state: RootState) => state.chain); const address = useSelector((state: RootState) => state.account.address); - // const { data: walletClient } = useWalletClient(); + const { data: walletClient } = useWalletClient(); const [ loggedIn, setLoggedIn ] = useState(false); @@ -41,30 +41,30 @@ export default function Account() { // handle wallet connect connection state (login/logout) - // useEffect(() => { - // console.log("walletClient changed", walletClient); - // async function login() { - // console.log("wallet connect login"); - // // const signer = await getEthersSigner({ chainId: parseInt(CHAIN_ID || "1") }); - // // if (signer === undefined) { - // // return; - // // } - // // const provider = signer.provider; - // // dispatch(connectChain(await getChainState(provider, true))); - // // setAccountRedux(signer, dispatch); + useEffect(() => { + console.log("walletClient changed", walletClient); + async function login() { + console.log("wallet connect login"); + const signer = await getEthersSigner({ chainId: parseInt(CHAIN_ID || "1") }); + if (signer === undefined) { + return; + } + const provider = signer.provider; + dispatch(connectChain(await getChainState(provider, true))); + setAccountRedux(signer, dispatch); - // // provider.on("block", (blockNumber: number) => { - // // getAndUpdateBlock(dispatch, provider, blockNumber); - // // }); - // } + provider.on("block", (blockNumber: number) => { + getAndUpdateBlock(dispatch, provider, blockNumber); + }); + } - // if (walletClient !== undefined && ! loggedIn) { - // login(); - // } else if (walletClient === undefined && loggedIn && isWalletConnect) { - // console.log("wallet connect logout") - // dispatch(disconnectChain()); - // } - // }, [walletClient, loggedIn, dispatch, isWalletConnect]); + if (walletClient !== undefined && ! loggedIn) { + login(); + } else if (walletClient === undefined && loggedIn && isWalletConnect) { + console.log("wallet connect logout") + dispatch(disconnectChain()); + } + }, [walletClient, loggedIn, dispatch, isWalletConnect]); if (! loggedIn) { diff --git a/src/components/account/login.tsx b/src/components/account/login.tsx index 0ceb162d..8e708204 100644 --- a/src/components/account/login.tsx +++ b/src/components/account/login.tsx @@ -47,9 +47,9 @@ export default function Login() { setShowLoginDialog(false)} /> - {/* + setShowLoginDialog(false)} /> - */} + diff --git a/src/components/account/logout.tsx b/src/components/account/logout.tsx index fcc2c229..0f604256 100644 --- a/src/components/account/logout.tsx +++ b/src/components/account/logout.tsx @@ -4,18 +4,19 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faRightFromBracket } from "@fortawesome/free-solid-svg-icons"; import { useDispatch, useSelector } from "react-redux"; import { removeSigner } from '../../utils/chain'; +import { useDisconnect } from 'wagmi'; export default function Logout() { const { t } = useTranslation('common'); const { isConnected, isWalletConnect } = useSelector((state: any) => state.chain); const dispatch = useDispatch(); - // const { disconnect: wagmiDisconnect } = useDisconnect(); + const { disconnect: wagmiDisconnect } = useDisconnect(); const logout = async () => { removeSigner(dispatch); - // if (isWalletConnect) { - // wagmiDisconnect(); - // } + if (isWalletConnect) { + wagmiDisconnect(); + } } let button = (<>); diff --git a/src/config/walletconnect.ts b/src/config/walletconnect.ts index c0d68e55..18f9f9ce 100644 --- a/src/config/walletconnect.ts +++ b/src/config/walletconnect.ts @@ -9,27 +9,26 @@ console.log("wallet connect config", "chainid", CHAIN_ID); export const WALLET_CONNECT_PROJECT_ID = process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID || ""; // configure walletconnect v2 -const chainsList = [] as any[]; -// if (CHAIN_ID === "80001") { -// // console.log("wallet connect config", "chainid", chainId, "polygonMumbai"); -// chainsList = [polygonMumbai]; -// } else if (CHAIN_ID === "1") { -// // console.log("wallet connect config", "chainid", chainId, "mainnet"); -// chainsList = [mainnet]; -// } else { -// // console.log("wallet connect config", "chainid", chainId, "mainnet"); -// chainsList = [mainnet]; -// } +let chainsList; +if (CHAIN_ID === "80001") { + // console.log("wallet connect config", "chainid", chainId, "polygonMumbai"); + chainsList = [polygonMumbai]; +} else if (CHAIN_ID === "1") { + // console.log("wallet connect config", "chainid", chainId, "mainnet"); + chainsList = [mainnet]; +} else { + // console.log("wallet connect config", "chainid", chainId, "mainnet"); + chainsList = [mainnet]; +} // console.log("wallet connect config", "chainsList", chainsList); // @ts-ignore testnet not set on mainnet chain - ignore complaint -// const { chains, publicClient } = configureChains(chainsList, [publicProvider()]); +const { chains, publicClient } = configureChains(chainsList, [publicProvider()]); // console.log("wallet connect config", "chains", chains, "publicClient", publicClient); -// export const wagmiConfig = createConfig({ -// autoConnect: false, -// connectors: w3mConnectors({ projectId: WALLET_CONNECT_PROJECT_ID, chains }), -// publicClient -// }); +export const wagmiConfig = createConfig({ + autoConnect: true, + connectors: w3mConnectors({ projectId: WALLET_CONNECT_PROJECT_ID, chains }), + publicClient +}); // console.log("wallet connect config", "wagmiConfig", wagmiConfig); -// export const ethereumClient = new EthereumClient(wagmiConfig, chains); -export const ethereumClient = undefined; +export const ethereumClient = new EthereumClient(wagmiConfig, chains); diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index d8d27109..8ddc8621 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -24,8 +24,8 @@ import '@fortawesome/fontawesome-svg-core/styles.css'; // Prevent fontawesome from adding its CSS since we did it manually above: import { config } from '@fortawesome/fontawesome-svg-core'; import { Web3Modal } from '@web3modal/react'; -// import { WagmiConfig } from 'wagmi'; -// import { WALLET_CONNECT_PROJECT_ID, ethereumClient, wagmiConfig } from '../config/walletconnect'; +import { WagmiConfig } from 'wagmi'; +import { WALLET_CONNECT_PROJECT_ID, ethereumClient, wagmiConfig } from '../config/walletconnect'; import { BundleAction, clearSelectedBundle, setBundleAction } from '../redux/slices/stakes'; import { bundleUnselected } from '../redux/slices/staking'; import { removeSigner } from '../utils/chain'; @@ -105,10 +105,10 @@ export function AppWithBlockchainConnection(appProps: AppProps) { return ( - {/* */} + - {/* - */} + + ); } diff --git a/src/utils/wallet.ts b/src/utils/wallet.ts index 572affb5..3c1c8242 100644 --- a/src/utils/wallet.ts +++ b/src/utils/wallet.ts @@ -9,19 +9,19 @@ import { store } from "../redux/store"; export async function reconnectWallets(dispatch: Dispatch) { // try to reconnect walletconnect connection first - // const wcSigner = await getEthersSigner({ chainId: parseInt(CHAIN_ID || "1") }); - // if (wcSigner !== undefined) { - // console.log("reconnect walletconnect"); - // const provider = wcSigner.provider; - // dispatch(connectChain(await getChainState(provider, true))); - // setAccountRedux(wcSigner, dispatch); + const wcSigner = await getEthersSigner({ chainId: parseInt(CHAIN_ID || "1") }); + if (wcSigner !== undefined) { + console.log("reconnect walletconnect"); + const provider = wcSigner.provider; + dispatch(connectChain(await getChainState(provider, true))); + setAccountRedux(wcSigner, dispatch); - // provider.on("block", (blockNumber: number) => { - // getAndUpdateBlock(dispatch, provider, blockNumber); - // }); + provider.on("block", (blockNumber: number) => { + getAndUpdateBlock(dispatch, provider, blockNumber); + }); - // return; - // } + return; + } // @ts-ignore if (window.ethereum !== undefined) { diff --git a/src/utils/walletconnect.ts b/src/utils/walletconnect.ts index 1ab06983..632ce6a6 100644 --- a/src/utils/walletconnect.ts +++ b/src/utils/walletconnect.ts @@ -1,23 +1,21 @@ -// import { type WalletClient, getWalletClient } from '@wagmi/core'; +import { type WalletClient, getWalletClient } from '@wagmi/core'; import { providers } from 'ethers'; -export function walletClientToSigner(walletClient: unknown) { - // const { account, chain, transport } = walletClient - // const network = { - // chainId: chain.id, - // name: chain.name, - // ensAddress: chain.contracts?.ensRegistry?.address, - // } - // const provider = new providers.Web3Provider(transport, network) - // const signer = provider.getSigner(account.address) - // return signer - return undefined; +export function walletClientToSigner(walletClient: WalletClient) { + const { account, chain, transport } = walletClient + const network = { + chainId: chain.id, + name: chain.name, + ensAddress: chain.contracts?.ensRegistry?.address, + } + const provider = new providers.Web3Provider(transport, network) + const signer = provider.getSigner(account.address) + return signer } /** Action to convert a viem Wallet Client to an ethers.js Signer. */ export async function getEthersSigner({ chainId }: { chainId?: number } = {}) { - // const walletClient = await getWalletClient({ chainId }) - // if (!walletClient) return undefined - // return walletClientToSigner(walletClient) - return undefined; + const walletClient = await getWalletClient({ chainId }) + if (!walletClient) return undefined + return walletClientToSigner(walletClient) }