diff --git a/packages/common/src/store/pages/token-dashboard/selectors.ts b/packages/common/src/store/pages/token-dashboard/selectors.ts index 5c3fa9dd94..1755d25eac 100644 --- a/packages/common/src/store/pages/token-dashboard/selectors.ts +++ b/packages/common/src/store/pages/token-dashboard/selectors.ts @@ -47,3 +47,5 @@ export const getCanRecipientReceiveWAudio = (state: CommonState) => { } return 'false' } +export const getConfirmingWallet = (state: CommonState) => + state.pages.tokenDashboard.associatedWallets.confirmingWallet diff --git a/packages/common/src/store/pages/token-dashboard/types.ts b/packages/common/src/store/pages/token-dashboard/types.ts index 40e1ca3e6c..39d19e39da 100644 --- a/packages/common/src/store/pages/token-dashboard/types.ts +++ b/packages/common/src/store/pages/token-dashboard/types.ts @@ -78,6 +78,7 @@ export type AssociatedWalletsState = { chain: Nullable balance: Nullable // TODO(nkang) `any` should be `BNWei` collectibleCount: Nullable + signature: Nullable } errorMessage: Nullable removeWallet: { diff --git a/packages/mobile/src/components/navigation-container/NavigationContainer.tsx b/packages/mobile/src/components/navigation-container/NavigationContainer.tsx index e217bb6555..7491ad6c18 100644 --- a/packages/mobile/src/components/navigation-container/NavigationContainer.tsx +++ b/packages/mobile/src/components/navigation-container/NavigationContainer.tsx @@ -61,7 +61,8 @@ const NavigationContainer = (props: NavigationContainerProps) => { initialRouteName: 'Wallets', screens: { Wallets: 'wallets', - ConfirmWalletConnection: 'wallet-connect' + ConfirmWalletConnection: 'wallet-connect', + ConfirmSignMessage: 'wallet-sign-message' } }, Feed: 'feed', @@ -141,8 +142,24 @@ const NavigationContainer = (props: NavigationContainerProps) => { // Add leading slash if it is missing if (path[0] !== '/') path = `/${path}` - // Remove the app-redirect prefix if present + const walletConnectPath = /^\/(wallet-connect)/ + if (path.match(walletConnectPath)) { + path = `${path.replace( + walletConnectPath, + '/wallets' + )}&path=wallet-connect` + } + + const walletSignPath = /^\/(wallet-sign-message)/ + if (path.match(walletSignPath)) { + path = `${path.replace( + walletSignPath, + '/wallets' + )}&path=wallet-sign-message` + } + if (path.match(`^/app-redirect`)) { + // Remove the app-redirect prefix if present path = path.replace(`/app-redirect`, '') } diff --git a/packages/mobile/src/screens/wallet-connect/ConfirmWalletConnectionScreen.tsx b/packages/mobile/src/screens/wallet-connect/ConfirmWalletConnectionScreen.tsx deleted file mode 100644 index 8acb5dd197..0000000000 --- a/packages/mobile/src/screens/wallet-connect/ConfirmWalletConnectionScreen.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { useLayoutEffect } from 'react' - -import { useRoute } from '@react-navigation/native' -import bs58 from 'bs58' -import { View } from 'react-native' -import nacl from 'tweetnacl' - -import { Button, Text } from 'app/components/core' -import { useAsyncStorage } from 'app/hooks/useAsyncStorage' -import { useNavigation } from 'app/hooks/useNavigation' -import { makeStyles } from 'app/styles' -import { spacing } from 'app/styles/spacing' - -import type { WalletConnectRoute } from './types' -import { decryptPayload, useDappKeyPair } from './utils' - -const messages = { - title: 'Your phantom public key:', - confirm: 'Confirm' -} - -const useStyles = makeStyles(() => ({ - root: { - padding: spacing(4), - alignItems: 'center' - } -})) - -export const ConfirmWalletConnectionScreen = () => { - const styles = useStyles() - const { params } = useRoute>() - const { phantom_encryption_public_key, data, nonce } = params - const [dappKeyPair] = useDappKeyPair() - const [, setSharedSecret] = useAsyncStorage('@phantom/sharedSecret') - const [, setSession] = useAsyncStorage('@phantom/session') - const [phantomWalletPublicKey, setPhantomWalletPublicKey] = useAsyncStorage( - '@phantom/walletPublicKey' - ) - const navigation = useNavigation() - - useLayoutEffect(() => { - if (!phantom_encryption_public_key) { - navigation.goBack() - } - if (dappKeyPair) { - const sharedSecretDapp = nacl.box.before( - bs58.decode(phantom_encryption_public_key), - dappKeyPair.secretKey - ) - const connectData = decryptPayload(data, nonce, sharedSecretDapp) - const { session, public_key } = connectData - setSharedSecret(sharedSecretDapp) - setSession(session) - setPhantomWalletPublicKey(public_key) - } - }, [ - dappKeyPair, - phantom_encryption_public_key, - data, - nonce, - setPhantomWalletPublicKey, - setSharedSecret, - setSession, - navigation - ]) - - return ( - - {messages.title} - {phantomWalletPublicKey} -