Skip to content

Commit

Permalink
fix(react): show recovery password modal for USER_MANAGED in `paper…
Browse files Browse the repository at this point in the history
…Wallet` (#1659)
  • Loading branch information
ElasticBottle authored Sep 26, 2023
1 parent bd18e4f commit ea5b9c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .changeset/strange-planets-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@thirdweb-dev/wallets": patch
"@thirdweb-dev/react": patch
---

fix(wallets/react): Show recovery modal for `USER_MANAGED` wallets in `paperWallet` implementation
11 changes: 6 additions & 5 deletions packages/react/src/wallet/wallets/paper/PaperOTPLoginUI.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PaperWallet } from "@thirdweb-dev/wallets";
import styled from "@emotion/styled";
import { ConnectUIProps, useWalletContext } from "@thirdweb-dev/react-core";
import { PaperWallet } from "@thirdweb-dev/wallets";
import { useCallback, useEffect, useRef, useState } from "react";
import { FadeIn } from "../../../components/FadeIn";
import { OTPInput } from "../../../components/OTPInput";
Expand All @@ -10,7 +11,6 @@ import { Button } from "../../../components/buttons";
import { Input } from "../../../components/formElements";
import { Text } from "../../../components/text";
import { Theme, fontSize } from "../../../design-system";
import styled from "@emotion/styled";
import { RecoveryShareManagement } from "./types";

type PaperOTPLoginUIProps = ConnectUIProps<PaperWallet> & {
Expand All @@ -19,6 +19,7 @@ type PaperOTPLoginUIProps = ConnectUIProps<PaperWallet> & {
type SentEmailInfo = {
isNewDevice: boolean;
isNewUser: boolean;
recoveryShareManagement: RecoveryShareManagement;
};
export const PaperOTPLoginUI: React.FC<PaperOTPLoginUIProps> = (props) => {
const email = props.selectionData;
Expand All @@ -38,9 +39,9 @@ export const PaperOTPLoginUI: React.FC<PaperOTPLoginUIProps> = (props) => {
>(null);

const recoveryCodeRequired = !!(
props.recoveryShareManagement !== "AWS_MANAGED" &&
sentEmailInfo &&
sentEmailInfo !== "error" &&
sentEmailInfo.recoveryShareManagement !== "AWS_MANAGED" &&
sentEmailInfo.isNewDevice &&
!sentEmailInfo.isNewUser
);
Expand All @@ -55,12 +56,12 @@ export const PaperOTPLoginUI: React.FC<PaperOTPLoginUIProps> = (props) => {
setWallet(_wallet);
const _paperSDK = await _wallet.getPaperSDK();

const { isNewDevice, isNewUser } =
const { isNewDevice, isNewUser, recoveryShareManagement } =
await _paperSDK.auth.sendPaperEmailLoginOtp({
email: email,
});

setSentEmailInfo({ isNewDevice, isNewUser });
setSentEmailInfo({ isNewDevice, isNewUser, recoveryShareManagement });
} catch (e) {
console.error(e);
setVerifyStatus("idle");
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
"@magic-ext/connect": "^6.7.2",
"@magic-ext/oauth": "^7.6.2",
"@magic-sdk/provider": "^13.6.2",
"@paperxyz/embedded-wallet-service-sdk": "^1.2.3",
"@paperxyz/embedded-wallet-service-sdk": "^1.2.4",
"@paperxyz/sdk-common-utilities": "^0.1.0",
"@safe-global/safe-core-sdk": "^3.3.4",
"@safe-global/safe-ethers-adapters": "0.1.0-alpha.17",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea5b9c3

Please sign in to comment.