Skip to content

Commit

Permalink
fix: test, refactor, remove console.logs
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu committed Oct 4, 2023
1 parent 211b5dc commit 6a1edf0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/components/settings/SignerAccountMFA/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ const SignerAccountMFA = () => {
}

const hasDeviceShare = await deviceShareModule.isEnabled()
if (hasDeviceShare !== storeDeviceShare) {
if (storeDeviceShare) {
await deviceShareModule.createAndStoreDeviceFactor()
} else {
// Switch to password recovery factor such that we can delete the device factor
await mpcCoreKit.inputFactorKey(new BN(securityQuestionFactor, 'hex'))

await deviceShareModule.removeDeviceFactor()
}

if (!hasDeviceShare && storeDeviceShare) {
await deviceShareModule.createAndStoreDeviceFactor()
}

if (hasDeviceShare && !storeDeviceShare) {
// Switch to password recovery factor such that we can delete the device factor
await mpcCoreKit.inputFactorKey(new BN(securityQuestionFactor, 'hex'))
await deviceShareModule.removeDeviceFactor()
}
} catch (error) {
console.error(error)
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/wallets/mpc/__tests__/useMPCWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('useMPCWallet', () => {
it('should throw if mpcCoreKit is not initialized', () => {
const { result } = renderHook(() => useMPCWallet())
expect(result.current.resetAccount()).rejects.toEqual(
new Error('MPC Core Kit is not initialized or the user is not logged in'),
new Error('MPC Core Kit is not initialized or the user is not logged in'),
)
})
it('should reset an account by overwriting the metadata', async () => {
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/wallets/mpc/useMPCWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,13 @@ export const useMPCWallet = (): MPCWalletHook => {
})

if (mpcCoreKit.status === COREKIT_STATUS.REQUIRED_SHARE) {
console.log('Share required')
// Check if we have a device share stored
const deviceFactor = await getWebBrowserFactor(mpcCoreKit)
if (deviceFactor) {
console.log('Using device factor')
// Recover from device factor
const deviceFactorKey = new BN(deviceFactor, 'hex')
await mpcCoreKit.inputFactorKey(deviceFactorKey)
} else {
console.log('using password')
// Check password recovery
if (securityQuestions.isEnabled()) {
setWalletState(MPCWalletState.MANUAL_RECOVERY)
Expand Down

0 comments on commit 6a1edf0

Please sign in to comment.