From cf5beef17a7ae299a7dacd14dc9042756f0daa92 Mon Sep 17 00:00:00 2001 From: Kirill Ageychenko Date: Fri, 23 Jun 2023 19:17:24 +0800 Subject: [PATCH] feat: web3 browser handle wallet connect (#1127) Co-authored-by: iGroza --- src/components/web3-browser/web3-browser-helper.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/web3-browser/web3-browser-helper.ts b/src/components/web3-browser/web3-browser-helper.ts index 482489d03..4ecebc0cb 100644 --- a/src/components/web3-browser/web3-browser-helper.ts +++ b/src/components/web3-browser/web3-browser-helper.ts @@ -3,6 +3,7 @@ import {RefObject} from 'react'; import EventEmitter from 'events'; import {PhishingController} from '@metamask/phishing-controller'; +import {parseUri} from '@walletconnect/utils'; import {JsonRpcEngine, JsonRpcRequest, JsonRpcResponse} from 'json-rpc-engine'; import WebView, {WebViewMessageEvent} from 'react-native-webview'; import { @@ -11,7 +12,9 @@ import { WebViewNavigationEvent, } from 'react-native-webview/lib/WebViewTypes'; +import {app} from '@app/contexts'; import {DEBUG_VARS} from '@app/debug-vars'; +import {Events} from '@app/events'; import {WebViewLogger} from '@app/helpers/webview-logger'; import {Web3BrowserSession} from '@app/models/web3-browser-session'; import { @@ -151,6 +154,11 @@ export class Web3BrowserHelper extends EventEmitter { return false; } + if (parseUri(url)?.protocol === 'wc') { + app.emit(Events.onWalletConnectUri, url); + return false; + } + if (getOriginFromUrl(url) !== this.origin) { this.emit(WebViewEventsEnum.ACCOUNTS_CHANGED, []); }