diff --git a/src/components/common/ConnectWallet/WalletDetails.tsx b/src/components/common/ConnectWallet/WalletDetails.tsx index 29c09582a4..3421e0f8a7 100644 --- a/src/components/common/ConnectWallet/WalletDetails.tsx +++ b/src/components/common/ConnectWallet/WalletDetails.tsx @@ -2,7 +2,7 @@ import { Divider, Typography } from '@mui/material' import type { ReactElement } from 'react' import LockIcon from '@/public/images/common/lock.svg' -import MPCLogin from './MPCLogin' +import SocialSigner from '@/components/common/SocialSigner' import WalletLogin from '@/components/welcome/WelcomeLogin/WalletLogin' const WalletDetails = ({ onConnect }: { onConnect: () => void }): ReactElement => { @@ -18,7 +18,7 @@ const WalletDetails = ({ onConnect }: { onConnect: () => void }): ReactElement = - + ) } diff --git a/src/components/common/ConnectWallet/PasswordRecovery.tsx b/src/components/common/SocialSigner/PasswordRecovery.tsx similarity index 98% rename from src/components/common/ConnectWallet/PasswordRecovery.tsx rename to src/components/common/SocialSigner/PasswordRecovery.tsx index 3d39a514dd..3c4cfaad1a 100644 --- a/src/components/common/ConnectWallet/PasswordRecovery.tsx +++ b/src/components/common/SocialSigner/PasswordRecovery.tsx @@ -11,7 +11,7 @@ import { FormControl, } from '@mui/material' import { useState } from 'react' -import Track from '../Track' +import Track from '@/components/common/Track' import { FormProvider, useForm } from 'react-hook-form' import PasswordInput from '@/components/settings/SecurityLogin/SocialSignerMFA/PasswordInput' import ErrorMessage from '@/components/tx/ErrorMessage' diff --git a/src/components/common/SocialSigner/__tests__/PasswordRecovery.test.tsx b/src/components/common/SocialSigner/__tests__/PasswordRecovery.test.tsx new file mode 100644 index 0000000000..488a33cccf --- /dev/null +++ b/src/components/common/SocialSigner/__tests__/PasswordRecovery.test.tsx @@ -0,0 +1,48 @@ +import { fireEvent, render } from '@/tests/test-utils' +import { PasswordRecovery } from '@/components/common/SocialSigner/PasswordRecovery' +import { act, waitFor } from '@testing-library/react' + +describe('PasswordRecovery', () => { + it('displays an error if password is wrong', async () => { + const mockRecoverWithPassword = jest.fn(() => Promise.reject()) + const mockOnSuccess = jest.fn() + + const { getByText, getByLabelText } = render( + , + ) + + const passwordField = getByLabelText('Recovery password') + const submitButton = getByText('Submit') + + act(() => { + fireEvent.change(passwordField, { target: { value: 'somethingwrong' } }) + submitButton.click() + }) + + await waitFor(() => { + expect(mockOnSuccess).not.toHaveBeenCalled() + expect(getByText('Incorrect password')).toBeInTheDocument() + }) + }) + + it('calls onSuccess if password is correct', async () => { + const mockRecoverWithPassword = jest.fn(() => Promise.resolve()) + const mockOnSuccess = jest.fn() + + const { getByText, getByLabelText } = render( + , + ) + + const passwordField = getByLabelText('Recovery password') + const submitButton = getByText('Submit') + + act(() => { + fireEvent.change(passwordField, { target: { value: 'somethingCorrect' } }) + submitButton.click() + }) + + await waitFor(() => { + expect(mockOnSuccess).toHaveBeenCalled() + }) + }) +}) diff --git a/src/components/common/ConnectWallet/__tests__/MPCLogin.test.tsx b/src/components/common/SocialSigner/__tests__/SocialSignerLogin.test.tsx similarity index 52% rename from src/components/common/ConnectWallet/__tests__/MPCLogin.test.tsx rename to src/components/common/SocialSigner/__tests__/SocialSignerLogin.test.tsx index f32a167de3..57515f20a9 100644 --- a/src/components/common/ConnectWallet/__tests__/MPCLogin.test.tsx +++ b/src/components/common/SocialSigner/__tests__/SocialSignerLogin.test.tsx @@ -1,49 +1,46 @@ -import { act, fireEvent, render, waitFor } from '@/tests/test-utils' -import * as useWallet from '@/hooks/wallets/useWallet' -import * as chains from '@/hooks/useChains' +import { act, render, waitFor } from '@/tests/test-utils' -import MPCLogin, { _getSupportedChains } from '../MPCLogin' +import { SocialSigner, _getSupportedChains } from '@/components/common/SocialSigner' import { hexZeroPad } from '@ethersproject/bytes' import { type EIP1193Provider } from '@web3-onboard/common' import { ONBOARD_MPC_MODULE_LABEL } from '@/services/mpc/SocialLoginModule' import { type ChainInfo } from '@safe-global/safe-gateway-typescript-sdk' import { COREKIT_STATUS, type Web3AuthMPCCoreKit } from '@web3auth/mpc-core-kit' import SocialWalletService from '@/services/mpc/SocialWalletService' -import { getSocialWalletService, __setSocialWalletService } from '@/hooks/wallets/mpc/useSocialWallet' -import type TestSocialWalletService from '@/services/mpc/__mocks__/SocialWalletService' -import { MPCWalletState } from '@/services/mpc/interfaces' import { TxModalProvider } from '@/components/tx-flow' +import { fireEvent } from '@testing-library/react' +import { type ISocialWalletService } from '@/services/mpc/interfaces' jest.mock('@/services/mpc/SocialWalletService') -describe('MPCLogin', () => { +const mockWallet = { + address: hexZeroPad('0x1', 20), + chainId: '5', + label: ONBOARD_MPC_MODULE_LABEL, + provider: {} as unknown as EIP1193Provider, +} + +describe('SocialSignerLogin', () => { + let mockSocialWalletService: ISocialWalletService + beforeEach(() => { jest.resetAllMocks() - // set the mock social wallet service into our external store - __setSocialWalletService(new SocialWalletService({} as unknown as Web3AuthMPCCoreKit)) - const mockEthereumChain = { chainId: '1', chainName: 'Ethereum', disabledWallets: ['socialLogin'] } as ChainInfo - const mockGoerliChain = { chainId: '5', chainName: 'Goerli', disabledWallets: ['TallyHo'] } as ChainInfo - jest.spyOn(chains, 'default').mockReturnValue({ configs: [mockEthereumChain, mockGoerliChain] }) + + mockSocialWalletService = new SocialWalletService({} as unknown as Web3AuthMPCCoreKit) }) it('should render continue with connected account when on gnosis chain', async () => { const mockOnLogin = jest.fn() - // Mock a successful login - getSocialWalletService()?.setWalletState(MPCWalletState.READY) - const walletAddress = hexZeroPad('0x1', 20) - jest - .spyOn(chains, 'useCurrentChain') - .mockReturnValue({ chainId: '100', disabledWallets: [] } as unknown as ChainInfo) - jest.spyOn(useWallet, 'default').mockReturnValue({ - address: walletAddress, - chainId: '5', - label: ONBOARD_MPC_MODULE_LABEL, - provider: {} as unknown as EIP1193Provider, - }) const result = render( - + , ) @@ -61,15 +58,17 @@ describe('MPCLogin', () => { }) it('should render google login button and invoke the callback on connection if no wallet is connected on gnosis chain', async () => { - jest - .spyOn(chains, 'useCurrentChain') - .mockReturnValue({ chainId: '100', disabledWallets: [] } as unknown as ChainInfo) - jest.spyOn(useWallet, 'default').mockReturnValue(null) - const mockOnLogin = jest.fn() + const result = render( - + , ) @@ -92,27 +91,33 @@ describe('MPCLogin', () => { }) it('should disable the Google Login button with a message when not on gnosis chain', async () => { - jest - .spyOn(chains, 'useCurrentChain') - .mockReturnValue({ chainId: '1', disabledWallets: ['socialLogin'] } as unknown as ChainInfo) - - const result = render() + const result = render( + , + ) expect(result.getByText('Currently only supported on Goerli')).toBeInTheDocument() expect(await result.findByRole('button')).toBeDisabled() }) - it('should display Password Recovery and recover with correct password', async () => { - ;(getSocialWalletService() as TestSocialWalletService).__setPostLoginState(COREKIT_STATUS.REQUIRED_SHARE) + it('should display Password Recovery form and call onLogin if password recovery succeeds', async () => { const mockOnLogin = jest.fn() - jest - .spyOn(chains, 'useCurrentChain') - .mockReturnValue({ chainId: '100', disabledWallets: [] } as unknown as ChainInfo) - jest.spyOn(useWallet, 'default').mockReturnValue(null) + mockSocialWalletService.loginAndCreate = jest.fn(() => Promise.resolve(COREKIT_STATUS.REQUIRED_SHARE)) + mockSocialWalletService.getUserInfo = jest.fn(undefined) const result = render( - + , ) @@ -124,6 +129,7 @@ describe('MPCLogin', () => { expect(mockOnLogin).not.toHaveBeenCalled() const button = await result.findByRole('button') + act(() => { button.click() }) @@ -145,50 +151,6 @@ describe('MPCLogin', () => { }) }) - it('should display Password Recovery and not recover with wrong password', async () => { - ;(getSocialWalletService() as TestSocialWalletService).__setPostLoginState(COREKIT_STATUS.REQUIRED_SHARE) - const mockOnLogin = jest.fn() - jest - .spyOn(chains, 'useCurrentChain') - .mockReturnValue({ chainId: '100', disabledWallets: [] } as unknown as ChainInfo) - jest.spyOn(useWallet, 'default').mockReturnValue(null) - - const result = render( - - - , - ) - - await waitFor(() => { - expect(result.findByText('Continue with Google')).resolves.toBeDefined() - }) - - // We do not automatically invoke the callback as the user did not actively connect - expect(mockOnLogin).not.toHaveBeenCalled() - - const button = await result.findByRole('button') - act(() => { - button.click() - }) - - await waitFor(() => { - expect(result.findByText('Enter security password')).resolves.toBeDefined() - }) - - const passwordField = await result.findByLabelText('Recovery password') - const submitButton = await result.findByText('Submit') - - act(() => { - fireEvent.change(passwordField, { target: { value: 'Invalid password' } }) - submitButton.click() - }) - - await waitFor(() => { - expect(mockOnLogin).not.toHaveBeenCalled() - expect(result.findByText('Incorrect Password')).resolves.toBeDefined() - }) - }) - describe('getSupportedChains', () => { it('returns chain names where social login is enabled', () => { const mockEthereumChain = { chainId: '1', chainName: 'Ethereum', disabledWallets: ['socialLogin'] } as ChainInfo diff --git a/src/components/common/ConnectWallet/MPCLogin.tsx b/src/components/common/SocialSigner/index.tsx similarity index 79% rename from src/components/common/ConnectWallet/MPCLogin.tsx rename to src/components/common/SocialSigner/index.tsx index 18626fcf71..a772dba5e0 100644 --- a/src/components/common/ConnectWallet/MPCLogin.tsx +++ b/src/components/common/SocialSigner/index.tsx @@ -1,12 +1,12 @@ import { Box, Button, SvgIcon, Typography } from '@mui/material' -import { useCallback, useContext, useMemo } from 'react' -import { PasswordRecovery } from './PasswordRecovery' +import { useCallback, useContext, useMemo, useState } from 'react' +import { PasswordRecovery } from '@/components/common/SocialSigner/PasswordRecovery' import GoogleLogo from '@/public/images/welcome/logo-google.svg' import InfoIcon from '@/public/images/notifications/info.svg' import css from './styles.module.css' import useWallet from '@/hooks/wallets/useWallet' -import Track from '../Track' +import Track from '@/components/common/Track' import { CREATE_SAFE_EVENTS } from '@/services/analytics' import { MPC_WALLET_EVENTS } from '@/services/analytics/events/mpcWallet' import useChains, { useCurrentChain } from '@/hooks/useChains' @@ -17,7 +17,7 @@ import { type ChainInfo } from '@safe-global/safe-gateway-typescript-sdk' import { TxModalContext } from '@/components/tx-flow' import { COREKIT_STATUS } from '@web3auth/mpc-core-kit' import useSocialWallet from '@/hooks/wallets/mpc/useSocialWallet' -import { MPCWalletState } from '@/services/mpc/interfaces' +import madProps from '@/utils/mad-props' export const _getSupportedChains = (chains: ChainInfo[]) => { return chains @@ -38,17 +38,24 @@ const useIsSocialWalletEnabled = () => { return isSocialWalletEnabled(currentChain) } -const MPCLogin = ({ onLogin }: { onLogin?: () => void }) => { - const socialWalletService = useSocialWallet() - const userInfo = socialWalletService?.getUserInfo() - const { setTxFlow } = useContext(TxModalContext) - - const wallet = useWallet() - const loginPending = socialWalletService?.walletState === MPCWalletState.AUTHENTICATING - - const supportedChains = useGetSupportedChains() - const isMPCLoginEnabled = useIsSocialWalletEnabled() +type SocialSignerLoginProps = { + socialWalletService: ReturnType + wallet: ReturnType + supportedChains: ReturnType + isMPCLoginEnabled: ReturnType + onLogin?: () => void +} +export const SocialSigner = ({ + socialWalletService, + wallet, + supportedChains, + isMPCLoginEnabled, + onLogin, +}: SocialSignerLoginProps) => { + const [loginPending, setLoginPending] = useState(false) + const { setTxFlow } = useContext(TxModalContext) + const userInfo = socialWalletService?.getUserInfo() const isDisabled = loginPending || !isMPCLoginEnabled const recoverPassword = useCallback( @@ -68,16 +75,25 @@ const MPCLogin = ({ onLogin }: { onLogin?: () => void }) => { const login = async () => { if (!socialWalletService) return + setLoginPending(true) + const status = await socialWalletService.loginAndCreate() if (status === COREKIT_STATUS.LOGGED_IN) { onLogin?.() + setLoginPending(false) } if (status === COREKIT_STATUS.REQUIRED_SHARE) { setTxFlow( - , - () => socialWalletService.setWalletState(MPCWalletState.NOT_INITIALIZED), + { + onLogin?.() + setLoginPending(false) + }} + />, + () => {}, false, ) } @@ -152,4 +168,9 @@ const MPCLogin = ({ onLogin }: { onLogin?: () => void }) => { ) } -export default MPCLogin +export default madProps(SocialSigner, { + socialWalletService: useSocialWallet, + wallet: useWallet, + supportedChains: useGetSupportedChains, + isMPCLoginEnabled: useIsSocialWalletEnabled, +}) diff --git a/src/components/common/SocialSigner/styles.module.css b/src/components/common/SocialSigner/styles.module.css new file mode 100644 index 0000000000..e0521d7a56 --- /dev/null +++ b/src/components/common/SocialSigner/styles.module.css @@ -0,0 +1,16 @@ +.profileImg { + border-radius: var(--space-2); + width: 32px; + height: 32px; +} + +.profileData { + display: flex; + flex-direction: column; + align-items: flex-start; +} + +.loginError { + width: 100%; + margin: 0; +} diff --git a/src/components/welcome/WelcomeLogin/index.tsx b/src/components/welcome/WelcomeLogin/index.tsx index 24fc232d7d..53320dd717 100644 --- a/src/components/welcome/WelcomeLogin/index.tsx +++ b/src/components/welcome/WelcomeLogin/index.tsx @@ -1,4 +1,4 @@ -import MPCLogin from '@/components/common/ConnectWallet/MPCLogin' +import SocialSigner from '@/components/common/SocialSigner' import { AppRoutes } from '@/config/routes' import { Paper, SvgIcon, Typography, Divider, Link, Box } from '@mui/material' import SafeLogo from '@/public/images/logo-text.svg' @@ -35,7 +35,7 @@ const WelcomeLogin = () => { - + Already have a Safe Account? diff --git a/src/services/mpc/SocialWalletService.ts b/src/services/mpc/SocialWalletService.ts index be0418f051..3fa00d7a7e 100644 --- a/src/services/mpc/SocialWalletService.ts +++ b/src/services/mpc/SocialWalletService.ts @@ -8,7 +8,7 @@ import { DeviceShareRecovery } from '@/services/mpc/recovery/DeviceShareRecovery import { logError } from '../exceptions' import ErrorCodes from '../exceptions/ErrorCodes' import { asError } from '../exceptions/utils' -import { type ISocialWalletService, MPCWalletState } from './interfaces' +import { type ISocialWalletService } from './interfaces' /** * Singleton Service for accessing the social login wallet @@ -17,14 +17,11 @@ class SocialWalletService implements ISocialWalletService { private mpcCoreKit: Web3AuthMPCCoreKit private onConnect: () => Promise = () => Promise.resolve() - public walletState: MPCWalletState - private deviceShareRecovery: DeviceShareRecovery private securityQuestionRecovery: SecurityQuestionRecovery constructor(mpcCoreKit: Web3AuthMPCCoreKit) { this.mpcCoreKit = mpcCoreKit - this.walletState = MPCWalletState.NOT_INITIALIZED this.deviceShareRecovery = new DeviceShareRecovery(mpcCoreKit) this.securityQuestionRecovery = new SecurityQuestionRecovery(mpcCoreKit) } @@ -65,17 +62,12 @@ class SocialWalletService implements ISocialWalletService { this.onConnect = onConnect } - setWalletState(newState: MPCWalletState) { - this.walletState = newState - } - getUserInfo() { return this.mpcCoreKit.state.userInfo } async loginAndCreate(): Promise { try { - this.walletState = MPCWalletState.AUTHENTICATING await this.mpcCoreKit.loginWithOauth({ subVerifierDetails: { typeOfLogin: 'google', @@ -92,7 +84,6 @@ class SocialWalletService implements ISocialWalletService { // Check password recovery if (this.securityQuestionRecovery.isEnabled()) { trackEvent(MPC_WALLET_EVENTS.MANUAL_RECOVERY) - this.walletState = MPCWalletState.MANUAL_RECOVERY return this.mpcCoreKit.status } } @@ -101,7 +92,6 @@ class SocialWalletService implements ISocialWalletService { await this.finalizeLogin() return this.mpcCoreKit.status } catch (error) { - this.walletState = MPCWalletState.NOT_INITIALIZED console.error(error) return this.mpcCoreKit.status } @@ -110,10 +100,8 @@ class SocialWalletService implements ISocialWalletService { private async finalizeLogin() { if (this.mpcCoreKit.status === COREKIT_STATUS.LOGGED_IN) { await this.mpcCoreKit.commitChanges() - const address = await this.mpcCoreKit.provider?.request({ method: 'eth_accounts', params: [] }) + await this.mpcCoreKit.provider?.request({ method: 'eth_accounts', params: [] }) await this.onConnect() - - this.walletState = MPCWalletState.READY } } diff --git a/src/services/mpc/__mocks__/SocialWalletService.ts b/src/services/mpc/__mocks__/SocialWalletService.ts index e6f35c0ffe..7e78191dc3 100644 --- a/src/services/mpc/__mocks__/SocialWalletService.ts +++ b/src/services/mpc/__mocks__/SocialWalletService.ts @@ -1,6 +1,6 @@ import { COREKIT_STATUS, type UserInfo } from '@web3auth/mpc-core-kit' import { hexZeroPad } from 'ethers/lib/utils' -import { MPCWalletState, type ISocialWalletService } from '../interfaces' +import { type ISocialWalletService } from '../interfaces' /** * Manual mock for SocialWalletService @@ -11,7 +11,6 @@ import { MPCWalletState, type ISocialWalletService } from '../interfaces' class TestSocialWalletService implements ISocialWalletService { private fakePassword = 'Test1234!' private postLoginState = COREKIT_STATUS.LOGGED_IN - public walletState = MPCWalletState.NOT_INITIALIZED private _isMfaEnabled = false private onConnect: () => Promise = () => Promise.resolve() private userInfo: UserInfo = { @@ -25,9 +24,6 @@ class TestSocialWalletService implements ISocialWalletService { } getUserInfo(): UserInfo | undefined { - if (this.walletState !== MPCWalletState.READY) { - return undefined - } return this.userInfo } isMFAEnabled(): boolean { @@ -54,9 +50,6 @@ class TestSocialWalletService implements ISocialWalletService { async loginAndCreate(): Promise { return new Promise((resolve) => { - this.walletState = MPCWalletState.AUTHENTICATING - this.walletState = - this.postLoginState === COREKIT_STATUS.LOGGED_IN ? MPCWalletState.READY : MPCWalletState.MANUAL_RECOVERY this.onConnect().then(() => resolve(this.postLoginState)) }) } @@ -66,7 +59,6 @@ class TestSocialWalletService implements ISocialWalletService { } async recoverAccountWithPassword(password: string, storeDeviceFactor: boolean): Promise { if (this.fakePassword === password) { - this.walletState = MPCWalletState.READY await this.onConnect() return true } @@ -75,15 +67,7 @@ class TestSocialWalletService implements ISocialWalletService { } exportSignerKey(password: string): Promise { - if (this.walletState === MPCWalletState.READY) { - return Promise.resolve(hexZeroPad('0x1', 20)) - } - - throw new Error('Cannot export account if not logged in') - } - - setWalletState(state: MPCWalletState): void { - this.walletState = state + return Promise.resolve(hexZeroPad('0x1', 20)) } } diff --git a/src/services/mpc/__tests__/SocialWalletService.test.ts b/src/services/mpc/__tests__/SocialWalletService.test.ts index 8b30d13381..e3163b1069 100644 --- a/src/services/mpc/__tests__/SocialWalletService.test.ts +++ b/src/services/mpc/__tests__/SocialWalletService.test.ts @@ -11,7 +11,6 @@ import { ethers } from 'ethers' import BN from 'bn.js' import { hexZeroPad } from 'ethers/lib/utils' import SocialWalletService from '../SocialWalletService' -import { MPCWalletState } from '../interfaces' /** time until mock login resolves */ const MOCK_LOGIN_TIME = 1000 @@ -81,14 +80,6 @@ describe('useMPCWallet', () => { afterAll(() => { jest.useRealTimers() }) - it('should have state NOT_INITIALIZED initially', () => { - const testService = new SocialWalletService( - new MockMPCCoreKit(COREKIT_STATUS.LOGGED_IN, { - email: 'test@testermann.com', - } as unknown as UserInfo) as unknown as Web3AuthMPCCoreKit, - ) - expect(testService.walletState).toBe(MPCWalletState.NOT_INITIALIZED) - }) describe('triggerLogin', () => { it('should handle successful log in for SFA account', async () => { @@ -107,8 +98,6 @@ describe('useMPCWallet', () => { status = testService.loginAndCreate() }) - // While the login resolves we are in Authenticating state - expect(testService.walletState === MPCWalletState.AUTHENTICATING) expect(mockOnConnect).not.toHaveBeenCalled() // Resolve mock login @@ -119,7 +108,6 @@ describe('useMPCWallet', () => { // We should be logged in and onboard should get connected await waitFor(() => { expect(status).resolves.toEqual(COREKIT_STATUS.LOGGED_IN) - expect(testService.walletState === MPCWalletState.READY) expect(mockOnConnect).toHaveBeenCalled() expect(mockCoreKit.commitChanges).toHaveBeenCalled() }) @@ -150,7 +138,6 @@ describe('useMPCWallet', () => { }) // While the login resolves we are in Authenticating state - expect(testService.walletState === MPCWalletState.AUTHENTICATING) expect(mockOnConnect).not.toHaveBeenCalled() // Resolve mock login @@ -161,7 +148,6 @@ describe('useMPCWallet', () => { // We should be logged in and onboard should get connected await waitFor(() => { expect(status).resolves.toEqual(COREKIT_STATUS.LOGGED_IN) - expect(testService.walletState === MPCWalletState.READY) expect(mockOnConnect).toHaveBeenCalled() expect(mockCoreKit.commitChanges).toHaveBeenCalled() }) @@ -187,9 +173,6 @@ describe('useMPCWallet', () => { status = testService.loginAndCreate() }) - // While the login resolves we are in Authenticating state - expect(testService.walletState === MPCWalletState.AUTHENTICATING) - // Resolve mock login act(() => { jest.advanceTimersByTime(MOCK_LOGIN_TIME) @@ -198,7 +181,6 @@ describe('useMPCWallet', () => { // A missing second factor should result in manual recovery state await waitFor(() => { expect(status).resolves.toEqual(COREKIT_STATUS.REQUIRED_SHARE) - expect(testService.walletState === MPCWalletState.MANUAL_RECOVERY) expect(mockOnConnect).not.toHaveBeenCalled() expect(mockCoreKit.commitChanges).not.toHaveBeenCalled() }) @@ -280,7 +262,6 @@ describe('useMPCWallet', () => { act(() => testService.recoverAccountWithPassword('test', false)) await waitFor(() => { - expect(testService.walletState === MPCWalletState.READY) expect(mockOnConnect).toHaveBeenCalled() }) }) diff --git a/src/services/mpc/interfaces.ts b/src/services/mpc/interfaces.ts index 049d98869c..b76ace0eec 100644 --- a/src/services/mpc/interfaces.ts +++ b/src/services/mpc/interfaces.ts @@ -1,15 +1,8 @@ import type { COREKIT_STATUS, UserInfo } from '@web3auth/mpc-core-kit' -export enum MPCWalletState { - NOT_INITIALIZED, - AUTHENTICATING, - MANUAL_RECOVERY, - READY, -} - export interface ISocialWalletService { /** - * Opens a pop up with the google login and creates / restores the mpc wallet. + * Opens a popup with the Google login and creates / restores the mpc wallet. * * @returns the follow up status of the mpcCoreKit. */ @@ -24,7 +17,6 @@ export interface ISocialWalletService { /** * Tries to recover a social signer through the Security Questions module * - * @param onConnect * @param password entered recovery password * @param storeDeviceFactor if true a device factor will be added after successful recovery */ @@ -37,6 +29,9 @@ export interface ISocialWalletService { */ exportSignerKey(password: string): Promise + /** + * Returns true if MFA is enabled + */ isMFAEnabled(): boolean /** @@ -53,9 +48,5 @@ export interface ISocialWalletService { getUserInfo(): UserInfo | undefined - walletState: MPCWalletState - - setWalletState(state: MPCWalletState): void - setOnConnect(onConnect: () => Promise): void }