Skip to content

Commit

Permalink
feat: web3 browser handle wallet connect (#1127)
Browse files Browse the repository at this point in the history
Co-authored-by: iGroza <[email protected]>
  • Loading branch information
iGroza and iGroza authored Jun 23, 2023
1 parent 58ff713 commit cf5beef
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/web3-browser/web3-browser-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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, []);
}
Expand Down

0 comments on commit cf5beef

Please sign in to comment.