Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
54ac7d5
feat: Keystone integration
Charon-Fan Jul 7, 2025
0b01a84
fix: update modal options to use formSheetScreensOptions for Keystone…
Charon-Fan Jul 7, 2025
df9bd4d
fix: simplify QRCode rendering in QRRenderer component
Charon-Fan Jul 7, 2025
a816362
feat: add light and dark QR code icons for Keystone troubleshooting s…
Charon-Fan Jul 7, 2025
3440e90
fix: update Keystone onboarding navigation and SVG icon dimensions
Charon-Fan Jul 8, 2025
2fd4a32
feat: implement KeystoneWallet and related components for wallet func…
Charon-Fan Jul 8, 2025
83a1acf
Merge branch 'main' into feat/keystone-v2
Charon-Fan Jul 8, 2025
e718afc
refactor: update getPublicKeyFor method to accept an object and remov…
Charon-Fan Jul 8, 2025
2420a73
chore: remove unused deps
Charon-Fan Jul 8, 2025
d250eeb
fix: update CreatePin to use active wallet ID when creating a new wallet
Charon-Fan Jul 8, 2025
2d4363b
feat: enhance Ethereum signature handling in KeystoneWallet
Charon-Fan Jul 10, 2025
2556db8
Merge branch 'main' into feat/keystone-v2
Charon-Fan Jul 10, 2025
4c1701f
Merge branch 'main' into feat/keystone-v2
Charon-Fan Jul 14, 2025
5695bea
feat: refactor Keystone integration and improve wallet data handling
Charon-Fan Jul 18, 2025
1b2a38a
feat: enhance Keystone troubleshooting screen with step-by-step instr…
Charon-Fan Jul 18, 2025
f6b404f
feat: implement Keystone blocking logic and update access wallet navi…
Charon-Fan Jul 18, 2025
b2c32c2
Merge branch 'main' into feat/keystone-v2
Charon-Fan Jul 18, 2025
2b2c3b6
feat: add KeystoneWallet implementation and related tests
Charon-Fan Jul 21, 2025
82b9049
Merge branch 'main' into feat/keystone-v2
Charon-Fan Jul 21, 2025
93ea5df
Merge branch 'main' into feat/keystone-v2
Charon-Fan Jul 25, 2025
7cc45d2
fix: resolve icon color issue in dark mode
Charon-Fan Jul 25, 2025
3cdcc26
fix: resolve comments issues
Charon-Fan Jul 25, 2025
ef4da27
Merge branch 'main' into feat/keystone-v2
Charon-Fan Aug 4, 2025
934c363
fix: fix test issues
Charon-Fan Aug 5, 2025
3b99b39
Merge branch 'main' into feat/keystone-v2
Charon-Fan Aug 18, 2025
f9378ef
Merge branch 'main' into feat/keystone-v2
Charon-Fan Aug 25, 2025
1602e57
fix: yarn lock
Charon-Fan Aug 25, 2025
0fc9f26
feat: enhance wallet handling and add KeystoneWallet support
Charon-Fan Sep 3, 2025
44557a7
Merge branch 'main' into feat/keystone-v2
Charon-Fan Sep 3, 2025
7acfb4e
chore: update Podfile.lock to reflect dependency version changes
Charon-Fan Sep 3, 2025
b35a364
feat: update wallet removal logic to include Keystone wallets
Charon-Fan Sep 3, 2025
6f4724b
feat: allow removal of Keystone wallets in wallet management
Charon-Fan Sep 3, 2025
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
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,13 @@
"node": ">=20.18.0",
"yarn": ">=3.6.4"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"dependencies": {
"@ethereumjs/util": "9.1.0",
"@keystonehq/animated-qr": "0.10.0",
"@keystonehq/keystone-sdk": "0.11.3",
"@ngraveio/bc-ur": "1.1.13",
"react-native-popover-view": "6.1.0",
"react-native-progress": "5.0.1"
}
}
6 changes: 6 additions & 0 deletions packages/core-mobile/app/assets/icons/keystone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/core-mobile/app/assets/icons/keystone_logo_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/core-mobile/app/assets/icons/keystone_logo_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/core-mobile/app/assets/icons/qrcode_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/core-mobile/app/assets/icons/qrcode_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 136 additions & 0 deletions packages/core-mobile/app/new/common/components/KeystoneQrScanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import React, { useState, useCallback, useEffect } from 'react'
import { UR, URDecoder } from '@ngraveio/bc-ur'
import * as Progress from 'react-native-progress'
import { View, Text, SCREEN_WIDTH, useTheme } from '@avalabs/k2-alpine'
import { showKeystoneTroubleshooting } from 'features/keystone/utils'
import { QrCodeScanner } from './QrCodeScanner'
import { Space } from './Space'

const SCANNER_WIDTH = SCREEN_WIDTH - 64

interface Props {
urTypes: string[]
onSuccess: (ur: UR) => void
onError?: () => void
info?: string
}

export const KeystoneQrScanner: (props: Props) => JSX.Element = ({
info,
urTypes,
onSuccess,
onError
}) => {
const [urDecoder, setUrDecoder] = useState(new URDecoder())
const [progress, setProgress] = useState<number>(0)
const [showTroubleshooting, setShowTroubleshooting] = useState(false)
const { theme } = useTheme()

const progressColor = theme.isDark ? theme.colors.$white : theme.colors.$black
const handleError = useCallback(() => {
setUrDecoder(new URDecoder())
setShowTroubleshooting(true)
if (onError) {
onError()
}
}, [onError])

const showErrorSheet = useCallback(() => {
showKeystoneTroubleshooting({
errorCode: -1,
retry: () => {
setShowTroubleshooting(false)
setProgress(0)
}
})
}, [])

useEffect(() => {
if (showTroubleshooting && !onError) {
showErrorSheet()
}
}, [showTroubleshooting, showErrorSheet, onError])

const handleScan = useCallback(
(code: string) => {
if (showTroubleshooting) {
return
}
try {
urDecoder.receivePart(code)
if (!urDecoder.isComplete()) {
setProgress(urDecoder.estimatedPercentComplete())
return
}

if (urDecoder.isError()) {
handleError()
}

if (urDecoder.isSuccess()) {
const ur = urDecoder.resultUR()

if (urTypes.includes(ur.type)) {
setProgress(1)

onSuccess(ur)

setTimeout(() => {
setUrDecoder(new URDecoder())
setProgress(0)
})
} else {
throw new Error('Invalid qr code')
}
}
} catch (error) {
handleError()
}
},
[
setProgress,
onSuccess,
urDecoder,
urTypes,
handleError,
showTroubleshooting
]
)

return (
<View sx={{ alignItems: 'center', height: '100%' }}>
<QrCodeScanner
paused={showTroubleshooting}
onSuccess={handleScan}
vibrate={progress !== 1}
sx={{
width: SCANNER_WIDTH,
height: SCANNER_WIDTH
}}
/>
<View
sx={{
alignItems: 'center',
flexDirection: 'column'
}}>
<Space y={70} />
<Progress.Bar
borderRadius={8}
color={progressColor}
width={290}
height={16}
progress={progress}
style={{
opacity: [0, 1].includes(progress) ? 0 : 1
}}
/>
{info && (
<>
<Space y={32} />
<Text>{info}</Text>
</>
)}
</View>
</View>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const NavigationRedirect = (): null => {
} else if (
pathName === '/onboarding/mnemonic/confirmation' ||
pathName === '/onboarding/seedless/confirmation' ||
pathName === '/onboarding/keystone/confirmation' ||
(pathName === '/loginWithPinOrBiometry' && !isSignedIn)
) {
// @ts-ignore TODO: make routes typesafe
Expand Down
23 changes: 16 additions & 7 deletions packages/core-mobile/app/new/common/components/QrCodeScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ type Props = {
onSuccess: (data: string) => void
vibrate?: boolean
sx?: SxProp
paused?: boolean
}

export const QrCodeScanner = ({
onSuccess,
vibrate = false,
sx
sx,
paused = false
}: Props): React.JSX.Element | undefined => {
const {
theme: { colors }
Expand All @@ -40,20 +42,27 @@ export const QrCodeScanner = ({
)
const [data, setData] = useState<string>()

const handleSuccess = (scanningResult: BarcodeScanningResult): void => {
// expo-camera's onBarcodeScanned callback is not debounced, so we need to debounce it ourselves
setData(scanningResult.data)
}
useEffect(() => {
if (paused) {
setData(undefined)
}
}, [paused, setData])

useEffect(() => {
if (data) {
if (data && !paused) {
onSuccess(data)

if (vibrate) {
notificationAsync(NotificationFeedbackType.Success)
}
}
}, [data, onSuccess, vibrate])
}, [data, onSuccess, vibrate, paused])

const handleSuccess = (scanningResult: BarcodeScanningResult): void => {
if (paused) return
// expo-camera's onBarcodeScanned callback is not debounced, so we need to debounce it ourselves
setData(scanningResult.data)
}

const checkIosPermission = useCallback(async () => {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
} from 'services/network/consts'
import { selectIsSolanaSupportBlocked } from 'store/posthog/slice'
import { selectIsDeveloperMode } from 'store/settings/advanced'
import { WalletType } from 'services/wallet/types'
import { useActiveWallet } from './useActiveWallet'

/**
* Hook to get the combined primary networks (networks are merged together with same address)
Expand All @@ -21,20 +23,24 @@ export function useCombinedPrimaryNetworks(): {
} {
const isDeveloperMode = useSelector(selectIsDeveloperMode)
const isSolanaSupportBlocked = useSelector(selectIsSolanaSupportBlocked)
const wallet = useActiveWallet()

const networks = useMemo(() => {
const blockSolana =
isSolanaSupportBlocked || wallet.type === WalletType.KEYSTONE

// Test networks
if (isDeveloperMode) {
return isSolanaSupportBlocked
return blockSolana
? (TEST_PRIMARY_NETWORKS as Network[])
: [...TEST_PRIMARY_NETWORKS, NETWORK_SOLANA_DEVNET]
}

// Main networks
return isSolanaSupportBlocked
return blockSolana
? (MAIN_PRIMARY_NETWORKS as Network[])
: [...MAIN_PRIMARY_NETWORKS, NETWORK_SOLANA]
}, [isDeveloperMode, isSolanaSupportBlocked])
}, [isDeveloperMode, isSolanaSupportBlocked, wallet.type])

return { networks }
}
19 changes: 15 additions & 4 deletions packages/core-mobile/app/new/common/hooks/useManageWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,18 @@ export const useManageWallet = (): {
// 1. Seedless wallets cannot be removed
if (wallet.type === WalletType.SEEDLESS) return false

// 2. Mnemonic wallets can be removed if there are multiple mnemonic or seedless wallets
// 2. Mnemonic wallets can be removed if there are multiple mnemonic/seedless/keystone wallets
const walletCount = Object.values(wallets).filter(
w => w.type === WalletType.MNEMONIC || w.type === WalletType.SEEDLESS
w =>
w.type === WalletType.MNEMONIC ||
w.type === WalletType.SEEDLESS ||
w.type === WalletType.KEYSTONE
).length

const isLastRemovableMnemonic =
walletCount === 1 && wallet.type === WalletType.MNEMONIC
walletCount === 1 &&
(wallet.type === WalletType.MNEMONIC ||
wallet.type === WalletType.KEYSTONE)

return !isLastRemovableMnemonic
},
Expand All @@ -155,7 +160,13 @@ export const useManageWallet = (): {
})
}

if ([WalletType.MNEMONIC, WalletType.SEEDLESS].includes(wallet.type)) {
if (
[
WalletType.MNEMONIC,
WalletType.SEEDLESS,
WalletType.KEYSTONE
].includes(wallet.type)
) {
baseItems.push({
id: 'add_account',
title: 'Add account to this wallet'
Expand Down
Loading