Skip to content

Commit

Permalink
fix: walletconnect v2 deeplink for android OK-20872 (#3176)
Browse files Browse the repository at this point in the history
* fix: wc v2 deeplink handle for android

* fix: lint
  • Loading branch information
sidmorizon authored Jul 3, 2023
1 parent 90967e0 commit 847e2ef
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { hdAccount1, network } from '../@tests/stcMockData';
import { testPrepareAccounts, testSignTransaction } from '../@tests/stcPresetCase';
import {
testPrepareAccounts,
testSignTransaction,
} from '../@tests/stcPresetCase';

import { KeyringHd } from './KeyringHd';

Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/vaults/impl/stc/keyring/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './KeyringHardware';
export * from './KeyringHd';
export * from './KeyringImported';
export * from './KeyringWatching';
export * from './KeyringWatching';
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,10 @@ class ProviderApiWalletConnect extends WalletConnectClientForWallet {
// TODO save to DB?
console.log('WalletConnectV2 session_proposal APPROVE: ', session);

// TODO
// this.redirectToDapp({ })
if (session) {
// TODO redirectToDapp for V2 handler
// this.redirectToDapp({ })
}
} catch (error) {
const session = await this.web3walletV2?.rejectSession({
id: proposal.id,
Expand Down Expand Up @@ -529,6 +531,7 @@ class ProviderApiWalletConnect extends WalletConnectClientForWallet {

// TODO sessionV2 accounts and peer accounts matched check

// handleSessionRequest will call this.redirectToDapp()
const result = await this.handleSessionRequest({
networkImpl,
payload: params.request,
Expand Down
9 changes: 8 additions & 1 deletion packages/kit/src/routes/deepLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const processDeepLinkUrl = memoizee(
// - packages/app/app.json

// ** ios UniversalLink
// https://app.onekey.so/wc/connect/wc?uri=wc%3Aeb16df1f-1d3b-4018-9d18-28ef610cc1a4%401%3Fbridge%3Dhttps%253A%252F%252Fj.bridge.walletconnect.org%26key%3D0037246aefb211f98a8386d4bf7fd2a5344960bf98cb39c57fb312a098f2eb77
// https://app.onekey.so/wc/connect/wc?uri=wc%3Aeb16df1f-1d3b-4018-9d18-28ef610cc1a4%401%3Fbridge%3Dhttps%253A%252F%252Fj.bridge.walletconnect.org%26key%3D0037246aefb211f98a8386d4bf7fd2a5344960bf98cb39c57fb312a098f2eb77
if (
hostname === 'app.onekey.so' &&
path === WalletConnectUniversalLinkPath
Expand All @@ -61,6 +61,7 @@ const processDeepLinkUrl = memoizee(
}

// ** ios/android/desktop DeepLink
// onekey-wallet://wc
// onekey-wallet://wc?uri=wc%3Afa75a793-a3fb-48e4-8629-8f1f034ec6eb%401%3Fbridge%3Dhttps%253A%252F%252Fy.bridge.walletconnect.org%26key%3D9e97f71a32b4e629cb60106295dca54d733d124da480b4031d0d848b678fd610/
if (
scheme === ONEKEY_APP_DEEP_LINK ||
Expand All @@ -77,14 +78,20 @@ const processDeepLinkUrl = memoizee(
}

// ** WalletConnect uri DeepLink
// wc:
// wc:c157eb01-8262-40e4-963e-7ebee47d0eac@1?bridge=https%3A%2F%2F7.bridge.walletconnect.org&key=881d859aa3ae028e284dd03e3be1d09c486329a400509a39c85246813808956b
if (
scheme === WALLET_CONNECT_DEEP_LINK ||
scheme === WALLET_CONNECT_DEEP_LINK_NAME
) {
// V1
if (queryParams?.bridge && queryParams?.key) {
wcUri = url;
}
// V2
if (queryParams?.['relay-protocol'] && queryParams?.symKey) {
wcUri = url;
}
}

if (wcUri) {
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/src/views/ManageNetworks/Listing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
import { FC, useEffect } from 'react';
import { useCallback, useMemo, useRef, useState } from 'react';
import type { FC } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';

import { useNavigation } from '@react-navigation/core';
import { useFocusEffect } from '@react-navigation/native';
Expand Down

0 comments on commit 847e2ef

Please sign in to comment.