Skip to content

Commit

Permalink
feat(suite): Distinguish between standard/passphrase wallet (#12462)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik authored May 17, 2024
1 parent 3afd251 commit a86e287
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const StyledTooltip = styled(Tooltip)`
interface AddWalletButtonProps {
device: TrezorDevice;
instances: AcquiredDevice[];
addDeviceInstance: (instance: TrezorDevice) => Promise<void>;
addDeviceInstance: (instance: TrezorDevice, useEmptyPassphrase?: boolean) => Promise<void>;
selectDeviceInstance: (instance: TrezorDevice) => void;
}

Expand All @@ -45,9 +45,9 @@ export const AddWalletButton = ({
locks.includes(SUITE.LOCK_TYPE.DEVICE) ||
locks.includes(SUITE.LOCK_TYPE.UI);

const onAddWallet = () => {
const onAddWallet = ({ useEmptyPassphrase }: { useEmptyPassphrase: boolean }) => {
if (hasAtLeastOneWallet) {
addDeviceInstance(device);
addDeviceInstance(device, useEmptyPassphrase);
} else {
selectDeviceInstance(instances[0]);
}
Expand All @@ -68,7 +68,7 @@ export const AddWalletButton = ({
isFullWidth
icon="PLUS"
isDisabled={isLocked}
onClick={onAddWallet}
onClick={() => onAddWallet({ useEmptyPassphrase: true })}
>
<Translation id="TR_ADD_WALLET" />
</Button>
Expand All @@ -80,7 +80,7 @@ export const AddWalletButton = ({
isFullWidth
icon="PLUS"
isDisabled={isLocked}
onClick={onAddWallet}
onClick={() => onAddWallet({ useEmptyPassphrase: false })}
>
<Row gap={spacings.xs}>
<Translation id="TR_ADD_HIDDEN_WALLET" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ export const DeviceItem = ({ device, instances, onCancel, backgroundRoute }: Dev
handleRedirection();
};

const addDeviceInstance = async (instance: DeviceItemProps['device']) => {
await dispatch(createDeviceInstance({ device: instance }));
const addDeviceInstance = async (
instance: DeviceItemProps['device'],
useEmptyPassphrase?: boolean,
) => {
await dispatch(createDeviceInstance({ device: instance, useEmptyPassphrase }));
handleRedirection();
};

Expand Down

0 comments on commit a86e287

Please sign in to comment.