-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into swap/complete-orders
- Loading branch information
Showing
28 changed files
with
1,403 additions
and
1,174 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 56 additions & 3 deletions
59
apps/wallet-mobile/src/features/Swap/common/ConfirmRawTx/ConfirmRawTxWithHW.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,57 @@ | ||
export const ConfirmRawTxWithHW = () => { | ||
// TODO: Needs to be implemented | ||
return null | ||
import React, {useState} from 'react' | ||
import {ActivityIndicator, ScrollView} from 'react-native' | ||
|
||
import {LedgerConnect} from '../../../../HW' | ||
import {useSelectedWallet} from '../../../../SelectedWallet' | ||
import {DeviceId, DeviceObj, withBLE, withUSB} from '../../../../yoroi-wallets/hw' | ||
import {walletManager} from '../../../../yoroi-wallets/walletManager' | ||
import {LedgerTransportSwitch} from '../../useCases/ConfirmTxScreen/LedgerTransportSwitch' | ||
|
||
type TransportType = 'USB' | 'BLE' | ||
type Step = 'select-transport' | 'connect-transport' | 'loading' | ||
|
||
type Props = { | ||
onConfirm?: (options: {useUSB: boolean}) => void | ||
} | ||
|
||
export const ConfirmRawTxWithHW = ({onConfirm}: Props) => { | ||
const [transportType, setTransportType] = useState<TransportType>('USB') | ||
const [step, setStep] = useState<Step>('select-transport') | ||
const wallet = useSelectedWallet() | ||
|
||
const onSelectTransport = (transportType: TransportType) => { | ||
setTransportType(transportType) | ||
setStep('connect-transport') | ||
} | ||
|
||
const onConnectBLE = async (deviceId: DeviceId) => { | ||
await walletManager.updateHWDeviceInfo(wallet, withBLE(wallet, deviceId)) | ||
onConfirm?.({useUSB: false}) | ||
setStep('loading') | ||
} | ||
|
||
const onConnectUSB = async (deviceObj: DeviceObj) => { | ||
await walletManager.updateHWDeviceInfo(wallet, withUSB(wallet, deviceObj)) | ||
onConfirm?.({useUSB: true}) | ||
setStep('loading') | ||
} | ||
|
||
if (step === 'select-transport') { | ||
return ( | ||
<LedgerTransportSwitch | ||
onSelectBLE={() => onSelectTransport('BLE')} | ||
onSelectUSB={() => onSelectTransport('USB')} | ||
/> | ||
) | ||
} | ||
|
||
if (step === 'connect-transport') { | ||
return ( | ||
<ScrollView> | ||
<LedgerConnect useUSB={transportType === 'USB'} onConnectBLE={onConnectBLE} onConnectUSB={onConnectUSB} /> | ||
</ScrollView> | ||
) | ||
} | ||
|
||
return <ActivityIndicator size="large" color="black" /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.