From bdd3f545b3c28250012dc5795ae5464c28e4b3e0 Mon Sep 17 00:00:00 2001 From: "Ng Wing Tat, David" Date: Fri, 13 Oct 2023 17:45:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Skip=20session=20approval=20for?= =?UTF-8?q?=20in-app-browser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wallet-connect-client/wallet-connect-client.ts | 3 +++ .../wallet-connect-v2-client.ts | 13 +++++++++---- .../wallet-connect-request-screen.tsx | 14 +++++++++++++- app/utils/wallet-connect.ts | 9 +++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 app/utils/wallet-connect.ts diff --git a/app/models/wallet-connect-client/wallet-connect-client.ts b/app/models/wallet-connect-client/wallet-connect-client.ts index 8570d627..10739a47 100644 --- a/app/models/wallet-connect-client/wallet-connect-client.ts +++ b/app/models/wallet-connect-client/wallet-connect-client.ts @@ -63,6 +63,9 @@ export const WalletConnectClientModel = types const { peerMeta } = self.connector return COMMON_API_CONFIG.userAgent.includes(peerMeta.name) }, + get version() { + return 1 + }, })) .views(self => ({ shouldShowWalletConnectModal(payload: any) { diff --git a/app/models/wallet-connect-v2-client/wallet-connect-v2-client.ts b/app/models/wallet-connect-v2-client/wallet-connect-v2-client.ts index bb13772e..f7467cfd 100644 --- a/app/models/wallet-connect-v2-client/wallet-connect-v2-client.ts +++ b/app/models/wallet-connect-v2-client/wallet-connect-v2-client.ts @@ -8,6 +8,7 @@ import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx' import { DirectSignResponse } from '@cosmjs/proto-signing' import { logError } from '../../utils/error' +import { checkIsInAppBrowser } from '../../utils/wallet-connect'; import { withCurrentUser, withEnvironment, withNavigationStore } from '../extensions' @@ -28,6 +29,9 @@ export const WalletConnectV2ClientModel = types get isInAppBrowser() { return false; // TODO: implement user agent checking }, + get version() { + return 2; + }, })) .views(_ => ({ shouldShowWalletConnectModal(payload: any) { @@ -247,7 +251,7 @@ export const WalletConnectV2ClientModel = types method: 'session_proposal', ...proposal, } - // if (!self.isInAppBrowser) { + if (!checkIsInAppBrowser(proposal)) { // Show WalletConnect Modal for loading UX self.navigationStore.navigateTo({ routeName: 'App', @@ -259,10 +263,11 @@ export const WalletConnectV2ClientModel = types }, }), }) - // } + } else { + // Approve session request directly without user's interaction + self.approveSessionRequest(proposal) + } - // Approve session request directly without user's interaction - // self.approveSessionRequest(proposal) }, })) .actions(self => ({ diff --git a/app/screens/wallet-connect-request-screen/wallet-connect-request-screen.tsx b/app/screens/wallet-connect-request-screen/wallet-connect-request-screen.tsx index 5ae6c1ba..8ef9e747 100644 --- a/app/screens/wallet-connect-request-screen/wallet-connect-request-screen.tsx +++ b/app/screens/wallet-connect-request-screen/wallet-connect-request-screen.tsx @@ -8,6 +8,7 @@ import { WalletConnectStore } from "../../models/wallet-connect-store" import { color } from "../../theme" import { translate } from "../../i18n" +import { checkIsInAppBrowser } from "../../utils/wallet-connect" import { Button } from "../../components/button" import { LoadingLikeCoin } from "../../components/loading-likecoin" @@ -93,7 +94,18 @@ export class WalletConnectRequestScreen extends React.Component