From 82f4c43a5eaa906e67d1d536f1da5dd68768bfa6 Mon Sep 17 00:00:00 2001 From: Amira Nasri Date: Wed, 14 May 2025 19:04:59 +0100 Subject: [PATCH] update ws 9.0.1 --- frontend/package.json | 41 ++++++++++---------- frontend/src/pages/_app.js | 4 +- frontend/src/wallets/web3modal.js | 64 ++++++++++++++----------------- 3 files changed, 50 insertions(+), 59 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index e9bab80..dfba8d8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,30 +12,29 @@ "lint": "next lint" }, "dependencies": { - "@near-js/providers": "^1.0.1", - "@near-wallet-selector/bitte-wallet": "^8.10.0", - "@near-wallet-selector/core": "^8.10.0", - "@near-wallet-selector/ethereum-wallets": "^8.10.0", - "@near-wallet-selector/here-wallet": "^8.10.0", - "@near-wallet-selector/hot-wallet": "^8.10.0", - "@near-wallet-selector/ledger": "^8.10.0", - "@near-wallet-selector/meteor-wallet": "^8.10.0", - "@near-wallet-selector/meteor-wallet-app": "^8.10.0", - "@near-wallet-selector/modal-ui": "^8.10.0", - "@near-wallet-selector/my-near-wallet": "^8.10.0", - "@near-wallet-selector/near-mobile-wallet": "^8.10.0", - "@near-wallet-selector/nightly": "^8.10.0", - "@near-wallet-selector/react-hook": "^8.9.15", - "@near-wallet-selector/sender": "^8.10.0", - "@near-wallet-selector/welldone-wallet": "^8.10.0", - "@web3modal/wagmi": "^5.1.11", + "@near-wallet-selector/bitte-wallet": "^9.0.1", + "@near-wallet-selector/core": "^9.0.1", + "@near-wallet-selector/ethereum-wallets": "^9.0.1", + "@near-wallet-selector/here-wallet": "^9.0.1", + "@near-wallet-selector/hot-wallet": "^9.0.1", + "@near-wallet-selector/ledger": "^9.0.1", + "@near-wallet-selector/meteor-wallet": "^9.0.1", + "@near-wallet-selector/meteor-wallet-app": "^9.0.1", + "@near-wallet-selector/modal-ui": "^9.0.1", + "@near-wallet-selector/my-near-wallet": "^9.0.1", + "@near-wallet-selector/near-mobile-wallet": "^9.0.1", + "@near-wallet-selector/react-hook": "^9.0.1", + "@near-wallet-selector/sender": "^9.0.1", + "@near-wallet-selector/welldone-wallet": "^9.0.1", + "@reown/appkit": "^1.7.4", + "@reown/appkit-adapter-wagmi": "^1.7.4", + "@wagmi/core": "^2.17.1", "bootstrap": "^5", "bootstrap-icons": "^1.11.3", - "near-api-js": "^5.0.1", - "next": "14.2.5", + "near-api-js": "^5.0.0", + "next": "^15", "react": "^18", - "react-dom": "^18", - "wagmi": "^2.13.3" + "react-dom": "^18" }, "devDependencies": { "encoding": "^0.1.13", diff --git a/frontend/src/pages/_app.js b/frontend/src/pages/_app.js index 14fa8f8..4280920 100644 --- a/frontend/src/pages/_app.js +++ b/frontend/src/pages/_app.js @@ -13,7 +13,7 @@ import { setupHereWallet } from '@near-wallet-selector/here-wallet'; import { setupNearMobileWallet } from '@near-wallet-selector/near-mobile-wallet'; import { setupWelldoneWallet } from '@near-wallet-selector/welldone-wallet'; import { WalletSelectorProvider } from '@near-wallet-selector/react-hook'; -import { wagmiConfig, web3Modal } from '@/wallets/web3modal'; +import { wagmiAdapter, web3Modal } from '@/wallets/web3modal'; import { Navigation } from '@/components/Navigation'; import { NetworkId, CounterContract } from '@/config'; @@ -21,7 +21,7 @@ const walletSelectorConfig = { network: NetworkId, createAccessKeyFor: CounterContract, modules: [ - setupEthereumWallets({ wagmiConfig, web3Modal, alwaysOnboardDuringSignIn: true }), + setupEthereumWallets({ wagmiConfig: wagmiAdapter.wagmiConfig, web3Modal }), setupBitteWallet(), setupMeteorWallet(), setupMeteorWalletApp({contractId: CounterContract}), diff --git a/frontend/src/wallets/web3modal.js b/frontend/src/wallets/web3modal.js index 0ce852e..5c706e9 100644 --- a/frontend/src/wallets/web3modal.js +++ b/frontend/src/wallets/web3modal.js @@ -1,42 +1,34 @@ -import { injected,walletConnect } from '@wagmi/connectors'; -import { createConfig,http, reconnect } from '@wagmi/core'; -import { createWeb3Modal } from '@web3modal/wagmi'; - -import { EVMWalletChain,NetworkId } from '@/config'; - -// Config -const near = { - id: EVMWalletChain.chainId, - name: EVMWalletChain.name, - nativeCurrency: { - decimals: 18, - name: 'NEAR', - symbol: 'NEAR', - }, - rpcUrls: { - default: { http: [EVMWalletChain.rpc] }, - public: { http: [EVMWalletChain.rpc] }, - }, - blockExplorers: { - default: { - name: 'NEAR Explorer', - url: EVMWalletChain.explorer, - }, - }, - testnet: NetworkId === 'testnet', -}; +import { createAppKit } from "@reown/appkit/react"; +import { reconnect } from "@wagmi/core"; +import { nearTestnet } from "@reown/appkit/networks"; +import { WagmiAdapter } from "@reown/appkit-adapter-wagmi"; // Get your projectId at https://cloud.reown.com const projectId = '5bb0fe33763b3bea40b8d69e4269b4ae'; - -export const wagmiConfig = createConfig({ - chains: [near], - transports: { [near.id]: http() }, - connectors: [walletConnect({ projectId, showQrModal: false }), injected({ shimDisconnect: true })], +export const wagmiAdapter = new WagmiAdapter({ + projectId, + networks: [nearTestnet], }); -// Preserve login state on page reload -reconnect(wagmiConfig); +export const web3Modal = createAppKit({ + adapters: [wagmiAdapter], + projectId, + networks: [nearTestnet], + enableWalletConnect: true, + features: { + analytics: true, + swaps: false, + onramp: false, + email: false, // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA. + socials: false, // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA. + }, + coinbasePreference: "eoaOnly", // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA. + allWallets: "SHOW", +}); -// Modal for login -export const web3Modal = createWeb3Modal({ wagmiConfig, projectId }); +// force reconnecting if the user has already signed in with an ethereum wallet +// this is a workaround until `ethereum-wallets` supports the `reconnect` method +if (typeof window !== "undefined") { + const recentWallets = localStorage.getItem("near-wallet-selector:recentlySignedInWallets"); + recentWallets && recentWallets.includes("ethereum-wallets") && reconnect(wagmiAdapter.wagmiConfig) +}