Skip to content

Commit

Permalink
Merge pull request #512 from 0xsend/bb/handle-unsynced-key-slots
Browse files Browse the repository at this point in the history
Handle unsynced key slots
  • Loading branch information
0xBigBoss authored Jul 1, 2024
2 parents bf68cca + 6a024cc commit 09f8251
Show file tree
Hide file tree
Showing 16 changed files with 330 additions and 101 deletions.
1 change: 1 addition & 0 deletions packages/app/features/account/settings/SettingsNavLink.tsx
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
2 changes: 1 addition & 1 deletion packages/app/features/account/settings/backup/confirm.tsx
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

0 comments on commit 09f8251

Please sign in to comment.