From c645ec9ad7aaf958dc2e5d7aa17989be07b77971 Mon Sep 17 00:00:00 2001 From: Archit Date: Fri, 20 Sep 2024 12:50:24 +0530 Subject: [PATCH 1/3] redirect wc apps to native apps --- .../wallet-connect-v2-adapter/src/walletConnectV2Utils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts index 5a493b626..42694e49d 100644 --- a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts +++ b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts @@ -17,6 +17,13 @@ export async function sendJrpcRequest(signClient: ISignClient, chainId: nu if (!session) { throw providerErrors.disconnected(); } + + if (typeof window !== "undefined") { + if (session.peer.metadata.redirect && session.peer.metadata.redirect.native) { + window.location.href = session.peer.metadata.redirect.native; + } + } + return signClient.request({ topic: session.topic, chainId: `eip155:${chainId}`, From 7e75ff4c117737284b3ef27e0e739d59985035b0 Mon Sep 17 00:00:00 2001 From: smgv Date: Fri, 20 Sep 2024 14:30:57 +0530 Subject: [PATCH 2/3] checking mobile device or not --- demo/vue-app-new/package-lock.json | 124 +++++++++--------- .../src/walletConnectV2Utils.ts | 6 +- 2 files changed, 67 insertions(+), 63 deletions(-) diff --git a/demo/vue-app-new/package-lock.json b/demo/vue-app-new/package-lock.json index c574c5bdf..89b11039f 100644 --- a/demo/vue-app-new/package-lock.json +++ b/demo/vue-app-new/package-lock.json @@ -53,12 +53,12 @@ }, "../../packages/adapters/auth-adapter": { "name": "@web3auth/auth-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/base-provider": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/base-provider": "^9.0.2", "deepmerge": "^4.3.1" }, "engines": { @@ -71,11 +71,11 @@ }, "../../packages/adapters/base-evm-adapter": { "name": "@web3auth/base-evm-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/base-controllers": "^6.1.2", - "@web3auth/base": "^9.0.1" + "@web3auth/base": "^9.0.2" }, "engines": { "node": ">=18.x", @@ -87,11 +87,11 @@ }, "../../packages/adapters/base-solana-adapter": { "name": "@web3auth/base-solana-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/base-controllers": "^6.1.2", - "@web3auth/base": "^9.0.1", + "@web3auth/base": "^9.0.2", "bs58": "^5.0.0" }, "devDependencies": { @@ -107,11 +107,11 @@ }, "../../packages/adapters/coinbase-adapter": { "name": "@web3auth/coinbase-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { - "@web3auth/base": "^9.0.1", - "@web3auth/base-evm-adapter": "^9.0.1" + "@web3auth/base": "^9.0.2", + "@web3auth/base-evm-adapter": "^9.0.2" }, "devDependencies": { "@coinbase/wallet-sdk": "^4.0.4" @@ -127,12 +127,12 @@ }, "../../packages/adapters/default-evm-adapter": { "name": "@web3auth/default-evm-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { - "@web3auth/base": "^9.0.1", - "@web3auth/base-evm-adapter": "^9.0.1", - "@web3auth/wallet-connect-v2-adapter": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/base-evm-adapter": "^9.0.2", + "@web3auth/wallet-connect-v2-adapter": "^9.0.2", "mipd": "^0.0.7" }, "engines": { @@ -145,7 +145,7 @@ }, "../../packages/adapters/default-solana-adapter": { "name": "@web3auth/default-solana-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@solana/wallet-standard-features": "^1.2.0", @@ -154,9 +154,9 @@ "@wallet-standard/base": "^1.0.1", "@wallet-standard/features": "^1.0.3", "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/base-solana-adapter": "^9.0.1", - "@web3auth/solana-provider": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/base-solana-adapter": "^9.0.2", + "@web3auth/solana-provider": "^9.0.2", "bn.js": "^5.2.1" }, "engines": { @@ -169,12 +169,12 @@ }, "../../packages/adapters/torus-evm-adapter": { "name": "@web3auth/torus-evm-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/torus-embed": "^5.0.0", - "@web3auth/base": "^9.0.1", - "@web3auth/base-evm-adapter": "^9.0.1" + "@web3auth/base": "^9.0.2", + "@web3auth/base-evm-adapter": "^9.0.2" }, "engines": { "node": ">=18.x", @@ -186,14 +186,14 @@ }, "../../packages/adapters/torus-solana-adapter": { "name": "@web3auth/torus-solana-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/solana-embed": "^2.1.0", - "@web3auth/base": "^9.0.1", - "@web3auth/base-provider": "^9.0.1", - "@web3auth/base-solana-adapter": "^9.0.1", - "@web3auth/solana-provider": "^9.0.1" + "@web3auth/base": "^9.0.2", + "@web3auth/base-provider": "^9.0.2", + "@web3auth/base-solana-adapter": "^9.0.2", + "@web3auth/solana-provider": "^9.0.2" }, "engines": { "node": ">=18.x", @@ -206,17 +206,17 @@ }, "../../packages/adapters/wallet-connect-v2-adapter": { "name": "@web3auth/wallet-connect-v2-adapter", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@walletconnect/sign-client": "^2.16.1", "@walletconnect/types": "^2.16.1", "@walletconnect/utils": "^2.16.1", "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/base-evm-adapter": "^9.0.1", - "@web3auth/base-provider": "^9.0.1", - "@web3auth/ethereum-provider": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/base-evm-adapter": "^9.0.2", + "@web3auth/base-provider": "^9.0.2", + "@web3auth/ethereum-provider": "^9.0.2", "deepmerge": "^4.3.1" }, "engines": { @@ -229,7 +229,7 @@ }, "../../packages/base": { "name": "@web3auth/base", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/base-controllers": "^6.1.2", @@ -250,15 +250,15 @@ }, "../../packages/composables/modal-vue-composables": { "name": "@web3auth/modal-vue-composables", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { - "@web3auth/base": "^9.0.1", - "@web3auth/modal": "^9.0.1" + "@web3auth/base": "^9.0.2", + "@web3auth/modal": "^9.0.2" }, "devDependencies": { "@web3auth/auth": "^9.3.3", - "@web3auth/auth-adapter": "^9.0.1" + "@web3auth/auth-adapter": "^9.0.2" }, "engines": { "node": ">=18.x", @@ -271,21 +271,21 @@ }, "../../packages/modal": { "name": "@web3auth/modal", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { - "@web3auth/auth-adapter": "^9.0.1", - "@web3auth/base": "^9.0.1", - "@web3auth/base-provider": "^9.0.1", - "@web3auth/no-modal": "^9.0.1", - "@web3auth/ui": "^9.0.1", + "@web3auth/auth-adapter": "^9.0.2", + "@web3auth/base": "^9.0.2", + "@web3auth/base-provider": "^9.0.2", + "@web3auth/no-modal": "^9.0.2", + "@web3auth/ui": "^9.0.2", "deepmerge": "^4.3.1" }, "devDependencies": { "@svgr/webpack": "^8.1.0", "@toruslabs/isomorphic-style-loader": "^5.3.3", "@web3auth/auth": "^9.3.3", - "@web3auth/wallet-connect-v2-adapter": "^9.0.1", + "@web3auth/wallet-connect-v2-adapter": "^9.0.2", "css-loader": "^7.1.2", "postcss-prefix-selector": "^1.16.1", "style-loader": "^4.0.0", @@ -307,17 +307,17 @@ }, "../../packages/no-modal": { "name": "@web3auth/no-modal", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/base-provider": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/base-provider": "^9.0.2", "deepmerge": "^4.3.1" }, "devDependencies": { - "@web3auth/auth-adapter": "^9.0.1", - "@web3auth/wallet-connect-v2-adapter": "^9.0.1" + "@web3auth/auth-adapter": "^9.0.2", + "@web3auth/wallet-connect-v2-adapter": "^9.0.2" }, "engines": { "node": ">=18.x", @@ -339,13 +339,13 @@ }, "../../packages/plugins/solana-wallet-connector-plugin": { "name": "@web3auth/solana-wallet-connector-plugin", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/solana-embed": "^2.1.0", "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/no-modal": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/no-modal": "^9.0.2", "loglevel": "^1.9.2" }, "engines": { @@ -358,12 +358,12 @@ }, "../../packages/plugins/wallet-services-plugin": { "name": "@web3auth/wallet-services-plugin", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/no-modal": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/no-modal": "^9.0.2", "@web3auth/ws-embed": "^3.0.0", "loglevel": "^1.9.2" }, @@ -380,12 +380,12 @@ }, "../../packages/providers/base-provider": { "name": "@web3auth/base-provider", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/base-controllers": "^6.1.2", "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", + "@web3auth/base": "^9.0.2", "json-rpc-random-id": "^1.0.1" }, "devDependencies": { @@ -401,7 +401,7 @@ }, "../../packages/providers/ethereum-provider": { "name": "@web3auth/ethereum-provider", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@ethereumjs/util": "^9.1.0", @@ -409,8 +409,8 @@ "@toruslabs/eccrypto": "^5.0.4", "@toruslabs/http-helpers": "^7.0.0", "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/base-provider": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/base-provider": "^9.0.2", "assert": "^2.1.0", "bignumber.js": "^9.1.2", "bn.js": "^5.2.1", @@ -432,14 +432,14 @@ }, "../../packages/providers/solana-provider": { "name": "@web3auth/solana-provider", - "version": "9.0.1", + "version": "9.0.2", "license": "ISC", "dependencies": { "@toruslabs/base-controllers": "^6.1.2", "@toruslabs/tweetnacl-js": "^1.0.4", "@web3auth/auth": "^9.3.3", - "@web3auth/base": "^9.0.1", - "@web3auth/base-provider": "^9.0.1", + "@web3auth/base": "^9.0.2", + "@web3auth/base-provider": "^9.0.2", "bn.js": "^5.2.1", "bs58": "^5.0.0", "json-rpc-random-id": "^1.0.1" diff --git a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts index 42694e49d..9e06b09d2 100644 --- a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts +++ b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts @@ -12,13 +12,17 @@ async function getLastActiveSession(signClient: ISignClient): Promise(signClient: ISignClient, chainId: number, method: string, params: U): Promise { const session = await getLastActiveSession(signClient); if (!session) { throw providerErrors.disconnected(); } - if (typeof window !== "undefined") { + if (typeof window !== "undefined" && isMobileDevice()) { if (session.peer.metadata.redirect && session.peer.metadata.redirect.native) { window.location.href = session.peer.metadata.redirect.native; } From f6eea335bf9942b8616870ac7e849852751e33e4 Mon Sep 17 00:00:00 2001 From: smgv Date: Fri, 20 Sep 2024 14:56:47 +0530 Subject: [PATCH 3/3] redirect change --- .../wallet-connect-v2-adapter/src/walletConnectV2Utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts index 9e06b09d2..f627a32a8 100644 --- a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts +++ b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts @@ -24,7 +24,7 @@ export async function sendJrpcRequest(signClient: ISignClient, chainId: nu if (typeof window !== "undefined" && isMobileDevice()) { if (session.peer.metadata.redirect && session.peer.metadata.redirect.native) { - window.location.href = session.peer.metadata.redirect.native; + window.open(session.peer.metadata.redirect.native, "_blank"); } }