Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

used new useAuth hook for logIn #1868

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/gui/src/hooks/useWalletConnectCommand.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import api, { store, useGetLoggedInFingerprintQuery, useLogInMutation } from '@chia-network/api-react';
import { useOpenDialog } from '@chia-network/core';
import api, { store, useGetLoggedInFingerprintQuery } from '@chia-network/api-react';
import { useOpenDialog, useAuth } from '@chia-network/core';
import { Trans } from '@lingui/macro';
import debug from 'debug';
import React, { type ReactNode } from 'react';
Expand Down Expand Up @@ -71,7 +71,7 @@ function parseNotification(
export default function useWalletConnectCommand(options: UseWalletConnectCommandOptions) {
const { onNotification } = options;
const openDialog = useOpenDialog();
const [logIn] = useLogInMutation();
const { logIn } = useAuth();
const { data: currentFingerprint, isLoading: isLoadingLoggedInFingerprint } = useGetLoggedInFingerprintQuery();
const { getPairBySession } = useWalletConnectPairs();

Expand Down Expand Up @@ -197,10 +197,7 @@ export default function useWalletConnectCommand(options: UseWalletConnectCommand
// auto login before execute command
if (isDifferentFingerprint && allowConfirmationFingerprintChange) {
log('Changing fingerprint', fingerprint);
await logIn({
fingerprint,
type: 'skip',
}).unwrap();
await logIn(fingerprint);
}

// wait for sync
Expand Down
10 changes: 4 additions & 6 deletions packages/wallets/src/components/WalletAdd.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useGenerateMnemonicMutation, useAddPrivateKeyMutation, useLogInMutation } from '@chia-network/api-react';
import { ButtonLoading, Form, TextField, Flex, Loading, Logo, useShowError } from '@chia-network/core';
import { useGenerateMnemonicMutation, useAddPrivateKeyMutation } from '@chia-network/api-react';
import { ButtonLoading, Form, TextField, Flex, Loading, Logo, useAuth, useShowError } from '@chia-network/core';
import { Trans } from '@lingui/macro';
import { TextField as TextFieldMaterial, Typography, Grid, Container } from '@mui/material';
import React from 'react';
Expand All @@ -15,7 +15,7 @@ export default function WalletAdd() {
const navigate = useNavigate();
const [generateMnemonic, { data: words, isLoading }] = useGenerateMnemonicMutation();
const [addPrivateKey] = useAddPrivateKeyMutation();
const [logIn] = useLogInMutation();
const { logIn } = useAuth();
const methods = useForm<FormData>({
defaultValues: {
label: '',
Expand Down Expand Up @@ -45,9 +45,7 @@ export default function WalletAdd() {
...(label && { label: label.trim() }), // omit `label` if label is undefined/empty. backend returns an error if label is set and undefined/empty
}).unwrap();

await logIn({
fingerprint,
}).unwrap();
await logIn(fingerprint);

navigate('/dashboard/wallets/1');
} catch (error) {
Expand Down
9 changes: 4 additions & 5 deletions packages/wallets/src/components/WalletImport.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { english } from '@chia-network/api';
import { useAddPrivateKeyMutation, useLogInMutation } from '@chia-network/api-react';
import { useAddPrivateKeyMutation } from '@chia-network/api-react';
import {
AlertDialog,
Autocomplete,
Expand All @@ -11,6 +11,7 @@ import {
useOpenDialog,
useTrans,
TextField,
useAuth,
} from '@chia-network/core';
import { Trans } from '@lingui/macro';
import { Typography, Container, Grid } from '@mui/material';
Expand Down Expand Up @@ -39,7 +40,7 @@ type FormData = {
export default function WalletImport() {
const navigate = useNavigate();
const [addPrivateKey] = useAddPrivateKeyMutation();
const [logIn] = useLogInMutation();
const { logIn } = useAuth();
const trans = useTrans();
const openDialog = useOpenDialog();
const [mnemonicPasteOpen, setMnemonicPasteOpen] = React.useState(false);
Expand Down Expand Up @@ -125,9 +126,7 @@ export default function WalletImport() {
...(label && { label: label.trim() }), // omit `label` if label is undefined/empty. backend returns an error if label is set and undefined/empty
}).unwrap();

await logIn({
fingerprint,
}).unwrap();
await logIn(fingerprint);

navigate('/dashboard/wallets/1');
}
Expand Down