From 01131fd2dfeee1522d98a2eeddfec961f50b087b Mon Sep 17 00:00:00 2001 From: chaitanyapotti Date: Wed, 28 Jun 2023 16:46:29 +0800 Subject: [PATCH] Removes wallet connect v1 --- package-lock.json | 145 +------- .../wallet-connect-v1-adapter/README.md | 68 ---- .../wallet-connect-v1-adapter/package.json | 68 ---- .../wallet-connect-v1-adapter/src/config.ts | 30 -- .../wallet-connect-v1-adapter/src/index.ts | 2 - .../src/interface.ts | 10 - .../src/walletConnectV1adapter.ts | 328 ------------------ .../wallet-connect-v1-adapter/torus.config.js | 1 - .../tsconfig.build.json | 3 - .../wallet-connect-v1-adapter/tsconfig.json | 7 - .../webpack.config.js | 11 - packages/base/src/adapter/IAdapter.ts | 12 +- packages/base/src/wallet/index.ts | 2 - packages/modal/src/modalManager.ts | 9 +- packages/no-modal/src/noModal.ts | 12 - .../providers/ethereum-provider/package.json | 1 - .../WalletConnectProvider.ts | 185 ---------- .../src/providers/injectedProviders/index.ts | 1 - .../injectedProviders/walletConnectUtils.ts | 55 --- .../ui/src/components/ExternalWallets.tsx | 12 +- packages/ui/src/components/Modal.tsx | 5 - packages/ui/src/loginModal.tsx | 8 +- 22 files changed, 11 insertions(+), 964 deletions(-) delete mode 100644 packages/adapters/wallet-connect-v1-adapter/README.md delete mode 100644 packages/adapters/wallet-connect-v1-adapter/package.json delete mode 100644 packages/adapters/wallet-connect-v1-adapter/src/config.ts delete mode 100644 packages/adapters/wallet-connect-v1-adapter/src/index.ts delete mode 100644 packages/adapters/wallet-connect-v1-adapter/src/interface.ts delete mode 100644 packages/adapters/wallet-connect-v1-adapter/src/walletConnectV1adapter.ts delete mode 100644 packages/adapters/wallet-connect-v1-adapter/torus.config.js delete mode 100644 packages/adapters/wallet-connect-v1-adapter/tsconfig.build.json delete mode 100644 packages/adapters/wallet-connect-v1-adapter/tsconfig.json delete mode 100644 packages/adapters/wallet-connect-v1-adapter/webpack.config.js delete mode 100644 packages/providers/ethereum-provider/src/providers/injectedProviders/WalletConnectProvider.ts delete mode 100644 packages/providers/ethereum-provider/src/providers/injectedProviders/walletConnectUtils.ts diff --git a/package-lock.json b/package-lock.json index 01c812532..d820a860d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6069,43 +6069,6 @@ "uint8arrays": "^3.1.0" } }, - "node_modules/@walletconnect/crypto": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@walletconnect/crypto/-/crypto-1.0.3.tgz", - "integrity": "sha512-+2jdORD7XQs76I2Odgr3wwrtyuLUXD/kprNVsjWRhhhdO9Mt6WqVzOPu0/t7OHSmgal8k7SoBQzUc5hu/8zL/g==", - "dev": true, - "dependencies": { - "@walletconnect/encoding": "^1.0.2", - "@walletconnect/environment": "^1.0.1", - "@walletconnect/randombytes": "^1.0.3", - "aes-js": "^3.1.2", - "hash.js": "^1.1.7", - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/crypto/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, - "node_modules/@walletconnect/encoding": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@walletconnect/encoding/-/encoding-1.0.2.tgz", - "integrity": "sha512-CrwSBrjqJ7rpGQcTL3kU+Ief+Bcuu9PH6JLOb+wM6NITX1GTxR/MfNwnQfhLKK6xpRAyj2/nM04OOH6wS8Imag==", - "dev": true, - "dependencies": { - "is-typedarray": "1.0.0", - "tslib": "1.14.1", - "typedarray-to-buffer": "3.1.5" - } - }, - "node_modules/@walletconnect/encoding/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, "node_modules/@walletconnect/environment": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@walletconnect/environment/-/environment-1.0.1.tgz", @@ -6243,84 +6206,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, - "node_modules/@walletconnect/legacy-client": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@walletconnect/legacy-client/-/legacy-client-2.0.0.tgz", - "integrity": "sha512-v5L7rYk9loVnfvUf0mF+76bUPFaU5/Vh7mzL6/950CD/yoGdzYZ3Kj+L7mkC6HPMEGeQsBP1+sqBuiVGZ/aODA==", - "dev": true, - "dependencies": { - "@walletconnect/crypto": "^1.0.3", - "@walletconnect/encoding": "^1.0.2", - "@walletconnect/jsonrpc-utils": "^1.0.4", - "@walletconnect/legacy-types": "^2.0.0", - "@walletconnect/legacy-utils": "^2.0.0", - "@walletconnect/safe-json": "^1.0.1", - "@walletconnect/window-getters": "^1.0.1", - "@walletconnect/window-metadata": "^1.0.1", - "detect-browser": "^5.3.0", - "query-string": "^6.13.5" - } - }, - "node_modules/@walletconnect/legacy-client/node_modules/query-string": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz", - "integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==", - "dev": true, - "dependencies": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@walletconnect/legacy-types": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@walletconnect/legacy-types/-/legacy-types-2.0.0.tgz", - "integrity": "sha512-sOVrA7HUdbI1OwKyPOQU0/DdvTSVFlsXWpAk2K2WvP2erTkBWPMTJq6cv2BmKdoJ3p6gLApT7sd+jHi3OF71uw==", - "dependencies": { - "@walletconnect/jsonrpc-types": "^1.0.2" - } - }, - "node_modules/@walletconnect/legacy-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@walletconnect/legacy-utils/-/legacy-utils-2.0.0.tgz", - "integrity": "sha512-CPWxSVVXw0kgNCxvU126g4GiV3mzXmC8IPJ15twE46aJ1FX+RHEIfAzFMFz2F2+fEhBxL63A7dwNQKDXorRPcQ==", - "dev": true, - "dependencies": { - "@walletconnect/encoding": "^1.0.2", - "@walletconnect/jsonrpc-utils": "^1.0.4", - "@walletconnect/legacy-types": "^2.0.0", - "@walletconnect/safe-json": "^1.0.1", - "@walletconnect/window-getters": "^1.0.1", - "@walletconnect/window-metadata": "^1.0.1", - "detect-browser": "^5.3.0", - "query-string": "^6.13.5" - } - }, - "node_modules/@walletconnect/legacy-utils/node_modules/query-string": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz", - "integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==", - "dev": true, - "dependencies": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@walletconnect/logger": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@walletconnect/logger/-/logger-2.0.1.tgz", @@ -6335,24 +6220,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, - "node_modules/@walletconnect/randombytes": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@walletconnect/randombytes/-/randombytes-1.0.3.tgz", - "integrity": "sha512-35lpzxcHFbTN3ABefC9W+uBpNZl1GC4Wpx0ed30gibfO/y9oLdy1NznbV96HARQKSBV9J9M/rrtIvf6a23jfYw==", - "dev": true, - "dependencies": { - "@walletconnect/encoding": "^1.0.2", - "@walletconnect/environment": "^1.0.1", - "randombytes": "^2.1.0", - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/randombytes/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, "node_modules/@walletconnect/relay-api": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@walletconnect/relay-api/-/relay-api-1.0.9.tgz", @@ -6571,10 +6438,6 @@ "resolved": "packages/ui", "link": true }, - "node_modules/@web3auth/wallet-connect-v1-adapter": { - "resolved": "packages/adapters/wallet-connect-v1-adapter", - "link": true - }, "node_modules/@web3auth/wallet-connect-v2-adapter": { "resolved": "packages/adapters/wallet-connect-v2-adapter", "link": true @@ -6913,12 +6776,6 @@ "integrity": "sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ==", "dev": true }, - "node_modules/aes-js": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", - "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", - "dev": true - }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -28270,6 +28127,7 @@ "packages/adapters/wallet-connect-v1-adapter": { "name": "@web3auth/wallet-connect-v1-adapter", "version": "6.1.1", + "extraneous": true, "license": "ISC", "dependencies": { "@web3auth/base": "^6.1.1", @@ -28485,7 +28343,6 @@ "@toruslabs/base-controllers": "^3.1.0", "@toruslabs/http-helpers": "^4.0.0", "@toruslabs/openlogin-jrpc": "^4.6.0", - "@walletconnect/legacy-types": "2.0.0", "@walletconnect/utils": "^2.8.1", "@web3auth/base": "^6.1.1", "@web3auth/base-provider": "^6.1.1", diff --git a/packages/adapters/wallet-connect-v1-adapter/README.md b/packages/adapters/wallet-connect-v1-adapter/README.md deleted file mode 100644 index eac672338..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Web3Auth WalletConnect v1 Adapter - -[![npm version](https://img.shields.io/npm/v/@web3auth/wallet-connect-v1-adapter?label=%22%22)](https://www.npmjs.com/package/@web3auth/wallet-connect-v1-adapter/v/latest) -[![minzip](https://img.shields.io/bundlephobia/minzip/@web3auth/wallet-connect-v1-adapter?label=%22%22)](https://bundlephobia.com/result?p=@web3auth/wallet-connect-v1-adapter@latest) - -> Web3Auth is where passwordless auth meets non-custodial key infrastructure for Web3 apps and wallets. By aggregating OAuth (Google, Twitter, Discord) logins, different wallets and innovative Multi Party Computation (MPC) - Web3Auth provides a seamless login experience to every user on your application. - -Wallet connect v1 adapter allows your Web3Auth Instance to connect with wallet connect v1. -## 📖 Documentation - -Read more about the Web3Auth WalletConnect v1 Adapter in the [official Web3Auth Documentation](https://web3auth.io/docs/sdk/web/adapters/wallet-connect-v1). - -## 💡 Features -- Plug and Play, OAuth based Web3 Authentication Service -- Fully decentralized, non-custodial key infrastructure -- End to end Whitelabelable solution -- Threshold Cryptography based Key Reconstruction -- Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc) -- Support for WebAuthn & Passwordless Login -- Support for connecting to multiple wallets -- DApp Active Session Management - -...and a lot more - -## 📄 Basic Details - -- Adapter Name: `wallet-connect-v1` - -- Package Name: [`@web3auth/wallet-connect-v1-adapter`](https://web3auth.io/docs/sdk/web/adapters/wallet-connect-v1) - -- authMode: `DAPP` - -- chainNamespace: `EIP155` - -- Default: `YES` - -## 🔗 Installation - -```shell -npm install --save @web3auth/wallet-connect-v1-adapter -``` - -## 🩹 Example - - -```ts -import { WalletConnectV1Adapter } from "@web3auth/wallet-connect-v1-adapter"; - -const walletConnectV1Adapter = new WalletConnectV1Adapter({ - adapterSettings: { - infuraId: "YOUR_INFURA_ID", - }, -}); - -web3auth.configureAdapter(walletConnectV1Adapter); -``` - -Checkout the examples for your preferred blockchain and platform in our [examples repository](https://github.com/Web3Auth/examples/) - -## 🌐 Demo - -Checkout the [Web3Auth Demo](https://demo-app.web3auth.io/) to see how Web3Auth can be used in your application. - -## 💬 Troubleshooting and Support - -- Have a look at our [Community Portal](https://community.web3auth.io/) to see if anyone has any questions or issues you might be having. Feel free to reate new topics and we'll help you out as soon as possible. -- Checkout our [Troubleshooting Documentation Page](https://web3auth.io/docs/troubleshooting) to know the common issues and solutions. -- For Priority Support, please have a look at our [Pricing Page](https://web3auth.io/pricing.html) for the plan that suits your needs. diff --git a/packages/adapters/wallet-connect-v1-adapter/package.json b/packages/adapters/wallet-connect-v1-adapter/package.json deleted file mode 100644 index 6d055ecfc..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@web3auth/wallet-connect-v1-adapter", - "version": "6.1.1", - "description": "wallet connect v1 adapter for web3auth", - "keywords": [ - "@web3auth/wallet-connect-v1-adapter", - "web3auth", - "multichainWallet", - "blockchain", - "ethereum", - "walletconnect" - ], - "main": "dist/walletConnectV1Adapter.cjs.js", - "module": "dist/walletConnectV1Adapter.esm.js", - "unpkg": "dist/walletConnectV1Adapter.umd.min.js", - "jsdelivr": "dist/walletConnectV1Adapter.umd.min.js", - "types": "dist/types/index.d.ts", - "author": "Torus Labs", - "homepage": "https://github.com/Web3Auth/Web3Auth/tree/master/packages/adapters/wallet-connect-v1-adapter#readme", - "license": "ISC", - "scripts": { - "test": "mocha --config ../../../.mocharc.json test/**.ts", - "test-debugger": "mocha --config ../../../.mocharc.json --inspect-brk test/**.ts", - "dev": "torus-scripts start", - "build": "torus-scripts build", - "lint": "eslint --fix 'src/**/*.ts'", - "prepack": "npm run build", - "pre-commit": "lint-staged --cwd ." - }, - "files": [ - "dist", - "src" - ], - "peerDependencies": { - "@babel/runtime": "^7.x", - "@walletconnect/legacy-client": "^2.x", - "@walletconnect/legacy-types": "^2.x" - }, - "dependencies": { - "@web3auth/base": "^6.1.1", - "@web3auth/base-evm-adapter": "^6.1.1", - "@web3auth/ethereum-provider": "^6.1.1" - }, - "devDependencies": { - "@walletconnect/legacy-client": "~2.0.0", - "@walletconnect/legacy-types": "~2.0.0" - }, - "lint-staged": { - "!(*d).ts": [ - "eslint --cache --fix", - "prettier --write" - ] - }, - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Web3Auth/Web3Auth.git" - }, - "bugs": { - "url": "https://github.com/Web3Auth/Web3Auth/issues" - }, - "engines": { - "node": ">=16.18.1", - "npm": ">=8.x" - } -} diff --git a/packages/adapters/wallet-connect-v1-adapter/src/config.ts b/packages/adapters/wallet-connect-v1-adapter/src/config.ts deleted file mode 100644 index a5eaea6fe..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/src/config.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { CHAIN_NAMESPACES, IWalletConnectExtensionAdapter } from "@web3auth/base"; - -export const WALLET_CONNECT_EXTENSION_ADAPTERS: IWalletConnectExtensionAdapter[] = [ - { - name: "Rainbow", - chains: [CHAIN_NAMESPACES.EIP155], - logo: "https://images.web3auth.io/login-rainbow.svg", - mobile: { - native: "rainbow:", - universal: "https://rnbwapp.com", - }, - desktop: { - native: "", - universal: "", - }, - }, - { - name: "MetaMask", - chains: [CHAIN_NAMESPACES.EIP155], - logo: "https://images.web3auth.io/login-metamask.svg", - mobile: { - native: "metamask:", - universal: "https://metamask.app.link", - }, - desktop: { - native: "", - universal: "", - }, - }, -]; diff --git a/packages/adapters/wallet-connect-v1-adapter/src/index.ts b/packages/adapters/wallet-connect-v1-adapter/src/index.ts deleted file mode 100644 index b54614332..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./interface"; -export * from "./walletConnectV1adapter"; diff --git a/packages/adapters/wallet-connect-v1-adapter/src/interface.ts b/packages/adapters/wallet-connect-v1-adapter/src/interface.ts deleted file mode 100644 index 9f16392bf..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/src/interface.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { IWalletConnectOptions } from "@walletconnect/legacy-types"; -import { BaseAdapterSettings, INetworkSwitch } from "@web3auth/base"; - -interface IAdapterSettings extends IWalletConnectOptions { - skipNetworkSwitching?: boolean; - networkSwitchModal?: INetworkSwitch; -} -export interface WalletConnectV1AdapterOptions extends BaseAdapterSettings { - adapterSettings?: IAdapterSettings; -} diff --git a/packages/adapters/wallet-connect-v1-adapter/src/walletConnectV1adapter.ts b/packages/adapters/wallet-connect-v1-adapter/src/walletConnectV1adapter.ts deleted file mode 100644 index cb69da27e..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/src/walletConnectV1adapter.ts +++ /dev/null @@ -1,328 +0,0 @@ -import WalletConnect from "@walletconnect/legacy-client"; -import { - ADAPTER_CATEGORY, - ADAPTER_CATEGORY_TYPE, - ADAPTER_EVENTS, - ADAPTER_NAMESPACES, - ADAPTER_STATUS, - ADAPTER_STATUS_TYPE, - AdapterInitOptions, - AdapterNamespaceType, - CHAIN_NAMESPACES, - ChainNamespaceType, - CONNECTED_EVENT_DATA, - CustomChainConfig, - getChainConfig, - log, - SafeEventEmitterProvider, - UserInfo, - WALLET_ADAPTERS, - WalletConnectV1Data, - WalletInitializationError, - WalletLoginError, - Web3AuthError, -} from "@web3auth/base"; -import { BaseEvmAdapter } from "@web3auth/base-evm-adapter"; -import { WalletConnectProvider } from "@web3auth/ethereum-provider"; - -import { WALLET_CONNECT_EXTENSION_ADAPTERS } from "./config"; -import { WalletConnectV1AdapterOptions } from "./interface"; - -class WalletConnectV1Adapter extends BaseEvmAdapter { - readonly name: string = WALLET_ADAPTERS.WALLET_CONNECT_V1; - - readonly adapterNamespace: AdapterNamespaceType = ADAPTER_NAMESPACES.EIP155; - - readonly currentChainNamespace: ChainNamespaceType = CHAIN_NAMESPACES.EIP155; - - readonly type: ADAPTER_CATEGORY_TYPE = ADAPTER_CATEGORY.EXTERNAL; - - readonly adapterOptions: WalletConnectV1AdapterOptions; - - public status: ADAPTER_STATUS_TYPE = ADAPTER_STATUS.NOT_READY; - - public adapterData: WalletConnectV1Data = { - uri: "", - extensionAdapters: WALLET_CONNECT_EXTENSION_ADAPTERS, - }; - - public connector: WalletConnect | null = null; - - private wcProvider: WalletConnectProvider | null = null; - - constructor(options: WalletConnectV1AdapterOptions = {}) { - super(options); - this.adapterOptions = { ...options }; - } - - get connected(): boolean { - return !!this.connector?.connected; - } - - get provider(): SafeEventEmitterProvider | null { - if (this.status !== ADAPTER_STATUS.NOT_READY && this.wcProvider) { - return this.wcProvider.provider; - } - return null; - } - - set provider(_: SafeEventEmitterProvider | null) { - throw new Error("Not implemented"); - } - - async init(options: AdapterInitOptions = {}): Promise { - await super.init(); - super.checkInitializationRequirements(); - // Create a connector - this.connector = this.getWalletConnectInstance(); - this.wcProvider = new WalletConnectProvider({ config: { chainConfig: this.chainConfig as CustomChainConfig }, connector: this.connector }); - - this.emit(ADAPTER_EVENTS.READY, WALLET_ADAPTERS.WALLET_CONNECT_V1); - this.status = ADAPTER_STATUS.READY; - log.debug("initializing wallet connect v1 adapter"); - if (options.autoConnect) { - if (this.connected) { - try { - this.rehydrated = true; - await this.onConnectHandler({ accounts: this.connector.accounts, chainId: this.connector.chainId }); - } catch (error) { - log.error("wallet auto connect", error); - this.emit(ADAPTER_EVENTS.ERRORED, error); - } - } else { - this.status = ADAPTER_STATUS.NOT_READY; - this.emit(ADAPTER_EVENTS.CACHE_CLEAR); - } - } - } - - async connect(): Promise { - super.checkConnectionRequirements(); - if (!this.connector) throw WalletInitializationError.notReady("Wallet adapter is not ready yet"); - - if (this.connected) { - await this.onConnectHandler({ accounts: this.connector.accounts, chainId: this.connector.chainId }); - return this.provider; - } - - if (this.status !== ADAPTER_STATUS.CONNECTING) { - // for wallet connect qr code modal we have to create a new connector, coz wallet connect internally does not open - // modal again on existing instance if connection is pending. - if (this.adapterOptions.adapterSettings?.qrcodeModal) { - this.connector = this.getWalletConnectInstance(); - this.wcProvider = new WalletConnectProvider({ - config: { - chainConfig: this.chainConfig as CustomChainConfig, - // network switching can be skipped with custom ui - skipLookupNetwork: this.adapterOptions.adapterSettings?.skipNetworkSwitching, - }, - connector: this.connector, - }); - } - await this.createNewSession(); - this.status = ADAPTER_STATUS.CONNECTING; - this.emit(ADAPTER_EVENTS.CONNECTING, { adapter: WALLET_ADAPTERS.WALLET_CONNECT_V1 }); - } - return new Promise((resolve, reject) => { - if (!this.connector) { - reject(WalletInitializationError.notReady("Wallet adapter is not ready yet")); - return; - } - // for wallet connect default modal. - this.connector.on("modal_closed", async () => { - this.status = ADAPTER_STATUS.READY; - this.emit(ADAPTER_EVENTS.READY, WALLET_ADAPTERS.WALLET_CONNECT_V1); - return reject(new Error("User closed modal")); - }); - try { - // Subscribe to session connection - this.connector.on("connect", async (error: Error | null, payload: { params: { accounts: string[]; chainId: number }[] }) => { - if (error) { - this.emit(ADAPTER_EVENTS.ERRORED, error); - } - log.debug("connected event emitted by web3auth"); - await this.onConnectHandler(payload.params[0]); - return resolve(this.provider); - }); - } catch (error: unknown) { - log.error("Wallet connect v1 adapter error while connecting", error); - // ready again to be connected - this.status = ADAPTER_STATUS.READY; - this.rehydrated = true; - this.emit(ADAPTER_EVENTS.ERRORED, error); - reject( - error instanceof Web3AuthError - ? error - : WalletLoginError.connectionError(`Failed to login with wallet connect: ${(error as Error)?.message || ""}`) - ); - } - }); - } - - async getUserInfo(): Promise> { - if (!this.connected) throw WalletLoginError.notConnectedError("Not connected with wallet, Please login/connect first"); - return {}; - } - - async disconnect(options: { cleanup: boolean } = { cleanup: false }): Promise { - await super.disconnectSession(); - const { cleanup } = options; - if (!this.connector || !this.connected) throw WalletLoginError.notConnectedError("Not connected with wallet"); - await this.connector.killSession(); - this.rehydrated = false; - if (cleanup) { - this.connector = null; - this.status = ADAPTER_STATUS.NOT_READY; - this.wcProvider = null; - } else { - // ready to connect again - this.status = ADAPTER_STATUS.READY; - } - await super.disconnect(); - } - - public async addChain(chainConfig: CustomChainConfig, init = false): Promise { - super.checkAddChainRequirements(chainConfig, init); - const networkSwitch = this.adapterOptions.adapterSettings?.networkSwitchModal; - if (networkSwitch) { - await networkSwitch.addNetwork({ chainConfig, appOrigin: window.location.hostname }); - } - await this.wcProvider?.addChain(chainConfig); - this.addChainConfig(chainConfig); - } - - public async switchChain(params: { chainId: string }, init = false): Promise { - super.checkSwitchChainRequirements(params, init); - await this._switchChain({ chainId: params.chainId }, this.chainConfig as CustomChainConfig); - this.setAdapterSettings({ chainConfig: this.getChainConfig(params.chainId) as CustomChainConfig }); - } - - private async _switchChain(connectedChainConfig: Partial, chainConfig: CustomChainConfig): Promise { - const networkSwitch = this.adapterOptions.adapterSettings?.networkSwitchModal; - - if (networkSwitch) { - await networkSwitch.switchNetwork({ - currentChainConfig: chainConfig, - newChainConfig: connectedChainConfig, - appOrigin: window.location.hostname, - }); - } - await this.wcProvider?.switchChain({ chainId: chainConfig.chainId, lookup: false, addChain: false }); - } - - private async createNewSession(opts: { forceNewSession: boolean } = { forceNewSession: false }): Promise { - if (!this.connector) throw WalletInitializationError.notReady("Wallet adapter is not ready yet"); - if (opts.forceNewSession && this.connector.pending) { - await this.connector.killSession(); - } - // for wallet connect qr modal - if (this.adapterOptions?.adapterSettings?.qrcodeModal) { - await this.connector.createSession({ chainId: parseInt(this.chainConfig?.chainId || "0x1", 16) }); - return; - } - - // for web3auth qr code modal - return new Promise((resolve, reject) => { - if (!this.connector) { - reject(WalletInitializationError.notReady("Wallet adapter is not ready yet")); - return; - } - log.debug("creating new session for web3auth wallet connect"); - this.connector.on("display_uri", async (err, payload) => { - if (err) { - this.emit(ADAPTER_EVENTS.ERRORED, WalletLoginError.connectionError("Failed to display wallet connect qr code")); - return reject(err); - } - const uri = payload.params[0]; - this.updateAdapterData({ uri, extensionAdapters: WALLET_CONNECT_EXTENSION_ADAPTERS } as WalletConnectV1Data); - - this.connector?.off("display_uri"); - return resolve(); - }); - - this.connector.createSession({ chainId: parseInt(this.chainConfig?.chainId || "0x1", 16) }).catch((error) => { - log.error("error while creating new wallet connect session", error); - this.emit(ADAPTER_EVENTS.ERRORED, error); - return reject(error); - }); - }); - } - - private async onConnectHandler(params: { accounts: string[]; chainId: number }) { - if (!this.connector || !this.wcProvider) throw WalletInitializationError.notReady("Wallet adapter is not ready yet"); - if (!this.chainConfig) throw WalletInitializationError.invalidParams("Chain config is not set"); - - const { chainId } = params; - log.debug("connected chainId in hex"); - // This is to check if the connected wallet can return chainId - // in string or a number format. - let isDifferentChain = false; - if (typeof chainId === "string") { - isDifferentChain = chainId !== this.chainConfig.chainId; - } else if (typeof chainId === "number") { - isDifferentChain = chainId !== parseInt(this.chainConfig.chainId, 16); - } - if (isDifferentChain) { - const connectedChainConfig = getChainConfig(CHAIN_NAMESPACES.EIP155, chainId) || { - chainId: typeof chainId === "number" ? `0x${chainId.toString(16)}` : chainId, - displayName: "Unknown Network", - }; - - const isCustomUi = this.adapterOptions.adapterSettings?.qrcodeModal; - // skipping network is not allowed in default ui. We are use network switching modal for default ui. - if (!isCustomUi || (isCustomUi && !this.adapterOptions?.adapterSettings?.skipNetworkSwitching)) { - try { - await this.addChain(this.chainConfig, true); - await this._switchChain(connectedChainConfig, this.chainConfig); - this.connector = this.getWalletConnectInstance(); - } catch (error) { - log.error("error while chain switching", error); - // we need to create a new session since old session is already used and - // user needs to login again with correct chain with new qr code. - await this.createNewSession({ forceNewSession: true }); - this.emit( - ADAPTER_EVENTS.ERRORED, - WalletInitializationError.fromCode( - 5000, - `Not connected to correct network. Expected: ${this.chainConfig.displayName}, Current: ${ - connectedChainConfig?.displayName || chainId - }, Please switch to correct network from wallet` - ) - ); - this.status = ADAPTER_STATUS.READY; - this.rehydrated = true; - return; - } - } - } - await this.wcProvider.setupProvider(this.connector); - this.subscribeEvents(this.connector); - this.status = ADAPTER_STATUS.CONNECTED; - this.emit(ADAPTER_EVENTS.CONNECTED, { adapter: WALLET_ADAPTERS.WALLET_CONNECT_V1, reconnected: this.rehydrated } as CONNECTED_EVENT_DATA); - } - - private subscribeEvents(connector: WalletConnect): void { - connector.on("session_update", async (error: Error | null) => { - if (error) { - this.emit(ADAPTER_EVENTS.ERRORED, error); - } - }); - connector.on("disconnect", async (error: Error | null, _) => { - if (error) { - this.emit(ADAPTER_EVENTS.ERRORED, error); - } - log.debug("disconnect event emitted by web3auth"); - await super.disconnect(); - this.status = ADAPTER_EVENTS.READY; - }); - } - - private getWalletConnectInstance(): WalletConnect { - const walletConnectOptions = this.adapterOptions.adapterSettings || {}; - walletConnectOptions.bridge = walletConnectOptions.bridge || "https://bridge.walletconnect.org"; - // Create a connector - return new WalletConnect(walletConnectOptions); - } -} - -export { WalletConnectV1Adapter }; diff --git a/packages/adapters/wallet-connect-v1-adapter/torus.config.js b/packages/adapters/wallet-connect-v1-adapter/torus.config.js deleted file mode 100644 index 6df6a4932..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/torus.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../../torus.config"); diff --git a/packages/adapters/wallet-connect-v1-adapter/tsconfig.build.json b/packages/adapters/wallet-connect-v1-adapter/tsconfig.build.json deleted file mode 100644 index bcd8df0e9..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/tsconfig.build.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "include": ["src"] -} diff --git a/packages/adapters/wallet-connect-v1-adapter/tsconfig.json b/packages/adapters/wallet-connect-v1-adapter/tsconfig.json deleted file mode 100644 index d146a8b5c..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "include": ["src","test"], - "compilerOptions": { - "strict": true, - }, -} diff --git a/packages/adapters/wallet-connect-v1-adapter/webpack.config.js b/packages/adapters/wallet-connect-v1-adapter/webpack.config.js deleted file mode 100644 index 3945ce3d2..000000000 --- a/packages/adapters/wallet-connect-v1-adapter/webpack.config.js +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const path = require("path"); -const generateWebpackConfig = require("../../../webpack.config"); - -const pkg = require("./package.json"); - -const currentPath = path.resolve("."); - -const config = generateWebpackConfig({ currentPath, pkg }); - -module.exports = config; diff --git a/packages/base/src/adapter/IAdapter.ts b/packages/base/src/adapter/IAdapter.ts index 1edf8edf6..e242b879b 100644 --- a/packages/base/src/adapter/IAdapter.ts +++ b/packages/base/src/adapter/IAdapter.ts @@ -147,11 +147,7 @@ export abstract class BaseAdapter extends SafeEventEmitter implements IAdapte checkConnectionRequirements(): void { // we reconnect without killing existing wallet connect session on calling connect again. - if ( - (this.name === WALLET_ADAPTERS.WALLET_CONNECT_V1 || this.name === WALLET_ADAPTERS.WALLET_CONNECT_V2) && - this.status === ADAPTER_STATUS.CONNECTING - ) - return; + if (this.name === WALLET_ADAPTERS.WALLET_CONNECT_V2 && this.status === ADAPTER_STATUS.CONNECTING) return; else if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletInitializationError.notReady("Already connecting"); if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletLoginError.connectionError("Already connected"); @@ -281,12 +277,10 @@ export interface IWalletConnectExtensionAdapter { }; } -export interface WalletConnectV1Data { +export type WalletConnectV2Data = { uri: string; extensionAdapters: IWalletConnectExtensionAdapter[]; -} - -export type WalletConnectV2Data = WalletConnectV1Data; +}; export interface IAdapterDataEvent { adapterName: string; data: unknown; diff --git a/packages/base/src/wallet/index.ts b/packages/base/src/wallet/index.ts index 002abfa4c..a81338719 100644 --- a/packages/base/src/wallet/index.ts +++ b/packages/base/src/wallet/index.ts @@ -1,6 +1,5 @@ export const MULTI_CHAIN_ADAPTERS = { OPENLOGIN: "openlogin", - WALLET_CONNECT_V1: "wallet-connect-v1", WALLET_CONNECT_V2: "wallet-connect-v2", }; @@ -30,7 +29,6 @@ export type MULTI_CHAIN_ADAPTER_TYPE = (typeof MULTI_CHAIN_ADAPTERS)[keyof typeo export const ADAPTER_NAMES = { [MULTI_CHAIN_ADAPTERS.OPENLOGIN]: "OpenLogin", - [MULTI_CHAIN_ADAPTERS.WALLET_CONNECT_V1]: "Wallet Connect v1", [MULTI_CHAIN_ADAPTERS.WALLET_CONNECT_V2]: "Wallet Connect v2", [SOLANA_ADAPTERS.TORUS_SOLANA]: "Torus", [SOLANA_ADAPTERS.PHANTOM]: "Phantom", diff --git a/packages/modal/src/modalManager.ts b/packages/modal/src/modalManager.ts index f951f66ef..ce70d99a1 100644 --- a/packages/modal/src/modalManager.ts +++ b/packages/modal/src/modalManager.ts @@ -168,7 +168,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { } }); - let adapterNames = await Promise.all(adapterConfigurationPromises); + const adapterNames = await Promise.all(adapterConfigurationPromises); const hasInAppWallets = Object.values(this.walletAdapters).some((adapter) => { if (adapter.type !== ADAPTER_CATEGORY.IN_APP) return false; if (this.modalConfig.adapters?.[adapter.name]?.showOnModal !== true) return false; @@ -183,11 +183,6 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { }); log.debug(hasInAppWallets, this.walletAdapters, adapterNames, "hasInAppWallets"); - // if both wc1 and wc2 are configured, give precedence to wc2. - if (this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1] && this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V2]) { - delete this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1]; - adapterNames = adapterNames.filter((ad) => ad !== WALLET_ADAPTERS.WALLET_CONNECT_V1); - } // Now, initialize the adapters. const initPromises = adapterNames.map(async (adapterName) => { if (!adapterName) return; @@ -317,7 +312,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { this.loginModal.on(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, async (visibility: boolean) => { log.debug("is login modal visible", visibility); this.emit(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility); - const adapter = this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V2] || this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1]; + const adapter = this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V2]; if (adapter) { const walletConnectStatus = adapter?.status; log.debug("trying refreshing wc session", visibility, walletConnectStatus); diff --git a/packages/no-modal/src/noModal.ts b/packages/no-modal/src/noModal.ts index e5996aa82..4aafef54a 100644 --- a/packages/no-modal/src/noModal.ts +++ b/packages/no-modal/src/noModal.ts @@ -17,7 +17,6 @@ import { UserAuthInfo, UserInfo, WALLET_ADAPTER_TYPE, - WALLET_ADAPTERS, WalletInitializationError, WalletLoginError, Web3AuthError, @@ -169,17 +168,6 @@ export class Web3AuthNoModal extends SafeEventEmitter implements IWeb3Auth { `This wallet adapter belongs to ${adapter.adapterNamespace} which is incompatible with currently used namespace: ${providedChainConfig.chainNamespace}` ); - if (adapter.name === WALLET_ADAPTERS.WALLET_CONNECT_V2 && this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1]) { - throw WalletInitializationError.invalidParams( - "Either one of wallet connect v2 or wallet connect v1 can be used, wallet connect v1 is already added to adapter lists." - ); - } - if (adapter.name === WALLET_ADAPTERS.WALLET_CONNECT_V1 && this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V2]) { - throw WalletInitializationError.invalidParams( - "Either one of wallet connect v2 or wallet connect v1 can be used, wallet connect v2 is already added to adapter lists." - ); - } - if ( adapter.adapterNamespace === ADAPTER_NAMESPACES.MULTICHAIN && adapter.currentChainNamespace && diff --git a/packages/providers/ethereum-provider/package.json b/packages/providers/ethereum-provider/package.json index 8388d75de..2526fabee 100644 --- a/packages/providers/ethereum-provider/package.json +++ b/packages/providers/ethereum-provider/package.json @@ -26,7 +26,6 @@ "@toruslabs/base-controllers": "^3.1.0", "@toruslabs/http-helpers": "^4.0.0", "@toruslabs/openlogin-jrpc": "^4.6.0", - "@walletconnect/legacy-types": "2.0.0", "@walletconnect/utils": "^2.8.1", "@web3auth/base": "^6.1.1", "@web3auth/base-provider": "^6.1.1", diff --git a/packages/providers/ethereum-provider/src/providers/injectedProviders/WalletConnectProvider.ts b/packages/providers/ethereum-provider/src/providers/injectedProviders/WalletConnectProvider.ts deleted file mode 100644 index 446875f38..000000000 --- a/packages/providers/ethereum-provider/src/providers/injectedProviders/WalletConnectProvider.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { JRPCEngine, providerFromEngine } from "@toruslabs/openlogin-jrpc"; -import type { IConnector } from "@walletconnect/legacy-types"; -import { CHAIN_NAMESPACES, CustomChainConfig, getChainConfig, isHexStrict, log, WalletInitializationError, WalletLoginError } from "@web3auth/base"; -import { BaseProvider, BaseProviderConfig, BaseProviderState } from "@web3auth/base-provider"; -import { ethErrors } from "eth-rpc-errors"; - -import { createEthMiddleware } from "../../rpc/ethRpcMiddlewares"; -import { createJsonRpcClient } from "../../rpc/jrpcClient"; -import { getProviderHandlers } from "./walletConnectUtils"; - -export interface WalletConnectProviderConfig extends BaseProviderConfig { - chainConfig: Omit; -} - -export interface WalletConnectProviderState extends BaseProviderState { - accounts: string[]; -} - -export class WalletConnectProvider extends BaseProvider { - private connector: IConnector | null = null; - - constructor({ config, state, connector }: { config: WalletConnectProviderConfig; state?: BaseProviderState; connector?: IConnector }) { - super({ - config: { chainConfig: { ...config.chainConfig, chainNamespace: CHAIN_NAMESPACES.EIP155 }, skipLookupNetwork: !!config.skipLookupNetwork }, - state: { ...(state || {}), chainId: "loading", accounts: [] }, - }); - this.connector = connector || null; - } - - public static getProviderInstance = async (params: { - connector: IConnector; - chainConfig: Omit; - skipLookupNetwork: boolean; - }): Promise => { - const providerFactory = new WalletConnectProvider({ config: { chainConfig: params.chainConfig, skipLookupNetwork: params.skipLookupNetwork } }); - await providerFactory.setupProvider(params.connector); - return providerFactory; - }; - - public async enable(): Promise { - if (!this.connector) - throw ethErrors.provider.custom({ message: "Connector is not initialized, pass wallet connect connector in constructor", code: 4902 }); - await this.setupProvider(this.connector); - return this._providerEngineProxy.request({ method: "eth_accounts" }); - } - - public async setupProvider(connector: IConnector): Promise { - this.onConnectorStateUpdate(connector); - await this.setupEngine(connector); - } - - public async switchChain({ chainId, addChain = true, lookup = true }: { chainId: string; addChain?: boolean; lookup?: boolean }): Promise { - if (!this.connector) - throw ethErrors.provider.custom({ message: "Connector is not initialized, pass wallet connect connector in constructor", code: 4902 }); - const currentChainConfig = this.getChainConfig(chainId); - this.update({ - chainId: "loading", - }); - const { rpcTarget, displayName } = currentChainConfig; - if (addChain) { - try { - await this.connector.sendCustomRequest({ - method: "wallet_addEthereumChain", - params: [ - { - chainId, - chainName: displayName, - rpcUrls: [rpcTarget], - blockExplorerUrls: [currentChainConfig.blockExplorer], - nativeCurrency: { - name: currentChainConfig.tickerName, - symbol: currentChainConfig.ticker, - decimals: currentChainConfig.decimals || 18, - }, - }, - ], - }); - } catch (error) { - log.error(error); - } - } - - try { - await this.connector.sendCustomRequest({ - method: "wallet_switchEthereumChain", - params: [{ chainId }], - }); - } catch (error) { - log.error(error); - // ignore this error because metamask & others return provider.result as null - // wallet connect thinks this is wrong - if (error.message !== "JSON RPC response format is invalid") { - throw error; - } - } - - this.configure({ chainConfig: currentChainConfig }); - if (lookup) await this.lookupNetwork(this.connector); - } - - async addChain(chainConfig: CustomChainConfig): Promise { - if (!this.connector) throw WalletInitializationError.notReady("Wallet adapter is not ready yet"); - const { rpcTarget, displayName } = chainConfig; - - try { - await this.connector.sendCustomRequest({ - method: "wallet_addEthereumChain", - params: [ - { - chainId: chainConfig.chainId, - chainName: displayName, - rpcUrls: [rpcTarget], - blockExplorerUrls: [chainConfig.blockExplorer], - nativeCurrency: { - name: chainConfig.tickerName, - symbol: chainConfig.ticker, - decimals: chainConfig.decimals || 18, - }, - }, - ], - }); - super.addChain(chainConfig); - } catch (error) { - log.error(error); - throw error; - } - } - - protected async lookupNetwork(connector: IConnector): Promise { - if (!connector.connected) throw WalletLoginError.notConnectedError("Wallet connect connector is not connected"); - if (!this.provider) throw ethErrors.provider.custom({ message: "Provider is not initialized", code: 4902 }); - const { chainId } = this.config.chainConfig; - const connectedHexChainId = isHexStrict(connector.chainId.toString()) ? connector.chainId : `0x${connector.chainId.toString(16)}`; - if (chainId !== connectedHexChainId) - throw WalletInitializationError.rpcConnectionError(`Invalid network, net_version is: ${connectedHexChainId}, expected: ${chainId}`); - - this.provider.emit("connect", { chainId }); - this.provider.emit("chainChanged", this.state.chainId); - return connectedHexChainId; - } - - private async setupEngine(connector: IConnector): Promise { - const providerHandlers = getProviderHandlers({ connector }); - this.update({ - accounts: connector.accounts || [], - }); - const ethMiddleware = createEthMiddleware(providerHandlers); - const engine = new JRPCEngine(); - const { networkMiddleware } = createJsonRpcClient(this.config.chainConfig as CustomChainConfig); - engine.push(ethMiddleware); - engine.push(networkMiddleware); - const provider = providerFromEngine(engine); - this.updateProviderEngineProxy(provider); - if (!this.config.skipLookupNetwork) await this.lookupNetwork(connector); - } - - private async onConnectorStateUpdate(connector: IConnector) { - connector.on("session_update", async (error: Error | null, payload) => { - if (!this.provider) throw WalletLoginError.notConnectedError("Wallet connect connector is not connected"); - if (error) { - this.provider.emit("error", error); - return; - } - const { accounts, chainId: connectedChainId, rpcUrl }: { accounts?: string[]; chainId?: number; rpcUrl?: string } = payload.params[0]; - // Check if accounts changed and trigger event - if (accounts?.length && this.state.accounts[0] !== accounts[0]) { - this.update({ - accounts, - }); - // await this.setupEngine(connector); - this.provider.emit("accountsChanged", accounts); - } - const connectedHexChainId = `0x${connectedChainId.toString(16)}`; - // Check if chainId changed and trigger event - if (connectedChainId && this.state.chainId !== connectedHexChainId) { - const maybeConfig = getChainConfig(CHAIN_NAMESPACES.EIP155, connectedChainId) || {}; - // Handle rpcUrl update - this.configure({ - chainConfig: { ...maybeConfig, chainId: connectedHexChainId, rpcTarget: rpcUrl, chainNamespace: CHAIN_NAMESPACES.EIP155 }, - }); - await this.setupEngine(connector); - } - }); - } -} diff --git a/packages/providers/ethereum-provider/src/providers/injectedProviders/index.ts b/packages/providers/ethereum-provider/src/providers/injectedProviders/index.ts index 9ec46a304..a5a3953dd 100644 --- a/packages/providers/ethereum-provider/src/providers/injectedProviders/index.ts +++ b/packages/providers/ethereum-provider/src/providers/injectedProviders/index.ts @@ -1,2 +1 @@ -export * from "./WalletConnectProvider"; export * from "./WalletConnectV2Provider"; diff --git a/packages/providers/ethereum-provider/src/providers/injectedProviders/walletConnectUtils.ts b/packages/providers/ethereum-provider/src/providers/injectedProviders/walletConnectUtils.ts deleted file mode 100644 index 8d343e804..000000000 --- a/packages/providers/ethereum-provider/src/providers/injectedProviders/walletConnectUtils.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { MessageTypes, TypedDataV1, TypedMessage } from "@metamask/eth-sig-util"; -import { JRPCRequest } from "@toruslabs/openlogin-jrpc"; -import type { IConnector, ITxData } from "@walletconnect/legacy-types"; -import { ethErrors } from "eth-rpc-errors"; - -import { IProviderHandlers, MessageParams, TransactionParams, TypedMessageParams } from "../../rpc/interfaces"; - -export function getProviderHandlers({ connector }: { connector: IConnector }): IProviderHandlers { - return { - getPrivateKey: async () => { - throw ethErrors.rpc.methodNotSupported(); - }, - getAccounts: async (_: JRPCRequest) => { - const { accounts } = connector; - if (accounts && accounts.length) { - return accounts; - } - throw new Error("Failed to get accounts"); - }, - processTransaction: async (txParams: TransactionParams, _: JRPCRequest): Promise => { - const result = await connector.sendTransaction(txParams as ITxData); - return result; - }, - processSignTransaction: async (txParams: TransactionParams, _: JRPCRequest): Promise => { - const result = await connector.signTransaction(txParams as ITxData); - return result; - }, - processEthSignMessage: async (msgParams: MessageParams, _: JRPCRequest): Promise => { - const result = await connector.signMessage([msgParams.from, msgParams.data]); - return result; - }, - processPersonalMessage: async (msgParams: MessageParams, _: JRPCRequest): Promise => { - const result = await connector.signPersonalMessage([msgParams.data, msgParams.from]); - return result; - }, - processTypedMessage: async (msgParams: MessageParams, _: JRPCRequest): Promise => { - const result = await connector.signTypedData([msgParams.from, msgParams.data]); - return result; - }, - processTypedMessageV3: async (msgParams: TypedMessageParams>): Promise => { - const result = await connector.signTypedData([msgParams.from, msgParams.data]); - return result; - }, - processTypedMessageV4: async (msgParams: TypedMessageParams>): Promise => { - const result = await connector.signTypedData([msgParams.from, msgParams.data]); - return result; - }, - processEncryptionPublicKey: async (_: string): Promise => { - throw ethErrors.rpc.methodNotSupported(); - }, - processDecryptMessage: (_: MessageParams): string => { - throw ethErrors.rpc.methodNotSupported(); - }, - }; -} diff --git a/packages/ui/src/components/ExternalWallets.tsx b/packages/ui/src/components/ExternalWallets.tsx index 3987b7357..c4d6c23c2 100644 --- a/packages/ui/src/components/ExternalWallets.tsx +++ b/packages/ui/src/components/ExternalWallets.tsx @@ -98,9 +98,7 @@ export default function ExternalWallet(props: ExternalWalletsProps) { useEffect(() => { log.debug("loaded external wallets", config, walletConnectUri, deviceType); - const walletConnectAdapterName = config[WALLET_ADAPTERS.WALLET_CONNECT_V1]?.showOnModal - ? WALLET_ADAPTERS.WALLET_CONNECT_V1 - : WALLET_ADAPTERS.WALLET_CONNECT_V2; + const walletConnectAdapterName = WALLET_ADAPTERS.WALLET_CONNECT_V2; const wcAvailable = (config[walletConnectAdapterName]?.showOnModal || false) !== false; if (wcAvailable && !walletConnectUri) { setIsLoaded(false); @@ -156,7 +154,7 @@ export default function ExternalWallet(props: ExternalWalletsProps) { } const adapterBtns = Object.keys(config) - .filter((adapter) => ![WALLET_ADAPTERS.WALLET_CONNECT_V1, WALLET_ADAPTERS.WALLET_CONNECT_V2].includes(adapter) && adapterVisibilityMap[adapter]) + .filter((adapter) => ![WALLET_ADAPTERS.WALLET_CONNECT_V2].includes(adapter) && adapterVisibilityMap[adapter]) .map((adapter) => ({ name: adapter, isLink: false, @@ -181,11 +179,7 @@ export default function ExternalWallet(props: ExternalWalletsProps) { {!isLoaded && } {/* */} {Object.keys(config).map((adapter) => { - if ( - walletConnectUri && - deviceDetails.platform === bowser.PLATFORMS_MAP.desktop && - [WALLET_ADAPTERS.WALLET_CONNECT_V1, WALLET_ADAPTERS.WALLET_CONNECT_V2].includes(adapter) - ) { + if (walletConnectUri && deviceDetails.platform === bowser.PLATFORMS_MAP.desktop && [WALLET_ADAPTERS.WALLET_CONNECT_V2].includes(adapter)) { return ; } return null; diff --git a/packages/ui/src/components/Modal.tsx b/packages/ui/src/components/Modal.tsx index 4e1f4b2ad..375b91919 100644 --- a/packages/ui/src/components/Modal.tsx +++ b/packages/ui/src/components/Modal.tsx @@ -121,14 +121,9 @@ export default function Modal(props: ModalProps) { const preHandleExternalWalletClick = useCallback( (params: ExternalWalletEventType) => { const { adapter } = params; - // if (DETAILED_ADAPTERS.includes(adapter)) setModalState((prevState) => { return { ...prevState, detailedLoaderAdapter: adapter, detailedLoaderAdapterName: ADAPTER_NAMES[adapter] }; }); - // else if (adapter !== WALLET_ADAPTERS.WALLET_CONNECT_V1) - // setModalState((prevState) => { - // return { ...prevState, detailedLoaderAdapter: "" }; - // }); handleExternalWalletClick(params); }, [handleExternalWalletClick] diff --git a/packages/ui/src/loginModal.tsx b/packages/ui/src/loginModal.tsx index c7cd751d5..23557f394 100644 --- a/packages/ui/src/loginModal.tsx +++ b/packages/ui/src/loginModal.tsx @@ -13,7 +13,6 @@ import { LoginMethodConfig, WALLET_ADAPTER_TYPE, WALLET_ADAPTERS, - WalletConnectV1Data, WalletConnectV2Data, Web3AuthError, } from "@web3auth/base"; @@ -290,10 +289,7 @@ class LoginModal extends SafeEventEmitter { }; private handleAdapterData = (adapterData: IAdapterDataEvent) => { - if (adapterData.adapterName === WALLET_ADAPTERS.WALLET_CONNECT_V1) { - const walletConnectData = adapterData.data as WalletConnectV1Data; - this.updateWalletConnect(walletConnectData.uri, walletConnectData.extensionAdapters); - } else if (adapterData.adapterName === WALLET_ADAPTERS.WALLET_CONNECT_V2) { + if (adapterData.adapterName === WALLET_ADAPTERS.WALLET_CONNECT_V2) { const walletConnectData = adapterData.data as WalletConnectV2Data; this.updateWalletConnect(walletConnectData.uri, walletConnectData.extensionAdapters); } @@ -304,7 +300,7 @@ class LoginModal extends SafeEventEmitter { log.info("connecting with adapter", data); // don't show loader in case of wallet connect, because currently it listens for incoming for incoming // connections without any user interaction. - if (data?.adapter !== WALLET_ADAPTERS.WALLET_CONNECT_V1 && data?.adapter !== WALLET_ADAPTERS.WALLET_CONNECT_V2) { + if (data?.adapter !== WALLET_ADAPTERS.WALLET_CONNECT_V2) { // const provider = data?.loginProvider || ""; this.setState({ status: MODAL_STATUS.CONNECTING });