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

Main #513

Merged
merged 8 commits into from
Jul 1, 2024
Merged

Main #513

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function SettingsNavLink({
$md={{ fontSize: '$5' }}
fontWeight={isActiveRoute ? 'bold' : '300'}
color={isActiveRoute ? iconActiveColor : iconInActiveColor}
pl="$4"
>
{text}
</Paragraph>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { baseMainnetClient, sendAccountAbi, tokenPaymasterAddress } from '@my/wa
import { useQuery } from '@tanstack/react-query'
import { SchemaForm } from 'app/utils/SchemaForm'
import { assert } from 'app/utils/assert'
import { COSEECDHAtoXY } from 'app/utils/passkeys'
import { byteaToBytes } from 'app/utils/byteaToBytes'
import { COSEECDHAtoXY } from 'app/utils/passkeys'
import { useSendAccount } from 'app/utils/send-accounts/useSendAccounts'
import { useSupabase } from 'app/utils/supabase/useSupabase'
import { throwIf } from 'app/utils/throwIf'
Expand Down
38 changes: 26 additions & 12 deletions packages/app/features/account/settings/backup/create.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createPasskey } from '@daimo/expo-passkeys'
import type { Tables } from '@my/supabase/database-generated.types'
import { H1, Paragraph, Spinner, SubmitButton, YStack } from '@my/ui'
import { H1, Paragraph, Shake, Spinner, SubmitButton, YStack } from '@my/ui'
import {
baseMainnetClient,
useReadSendAccountGetActiveSigningKeys,
Expand Down Expand Up @@ -104,7 +104,12 @@ const CreatePasskeyForm = ({
key_slot: keySlot,
}
)
throwIf(error)
if (error) {
if (error.code === '23505') {
throw new Error('Key slot already in use, delete the existing key slot and try again.')
}
throw error.message
}
assert(!!webauthnCred, 'Failed to save passkey')
onPasskeySaved(webauthnCred)
} catch (e) {
Expand All @@ -113,7 +118,7 @@ const CreatePasskeyForm = ({
e.details?.toString().split('.').at(0) ??
e.mesage?.split('.').at(0) ??
e.toString().split('.').at(0)
form.setError('accountName', {
form.setError('root', {
type: 'custom',
message,
})
Expand Down Expand Up @@ -150,15 +155,24 @@ const CreatePasskeyForm = ({
</Paragraph>
</YStack>
)}
renderAfter={({ submit }) =>
isLoading ? (
<Spinner size="small" color={'$color'} />
) : (
<SubmitButton mx="auto" px="$6" onPress={submit}>
Create Passkey
</SubmitButton>
)
}
renderAfter={({ submit }) => (
<>
{form.formState.errors?.root?.message ? (
<Shake>
<Paragraph color="red" testID="AccountSendTagScreen">
{form.formState.errors?.root?.message}
</Paragraph>
</Shake>
) : null}
{isLoading ? (
<Spinner size="small" color={'$color'} />
) : (
<SubmitButton mx="auto" px="$6" onPress={submit}>
Create Passkey
</SubmitButton>
)}
</>
)}
>
{(fields) => <>{Object.values(fields)}</>}
</SchemaForm>
Expand Down
Loading
Loading