Skip to content

Commit

Permalink
Pass connection
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljscript committed Oct 9, 2023
1 parent 07d3361 commit e6dc7b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export const ConfirmRawTx = ({
onHWConfirm,
}: {
onConfirm?: (rootKey: string) => Promise<void>
onHWConfirm?: VoidFunction
onHWConfirm?: ({useUSB}: {useUSB: boolean}) => Promise<void>
}) => {
const wallet = useSelectedWallet()

if (wallet.isHW) {
return <ConfirmRawTxWithHW onSuccess={onHWConfirm} />
return <ConfirmRawTxWithHW onConfirm={onHWConfirm} />
}

if (wallet.isEasyConfirmationEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ type TransportType = 'USB' | 'BLE'
type Step = 'select-transport' | 'connect-transport' | 'confirm' | 'loading'

type Props = {
onSuccess?: (options: {useUSB: boolean}) => void
onConfirm?: (options: {useUSB: boolean}) => void
}

export const ConfirmRawTxWithHW = ({onSuccess}: Props) => {
export const ConfirmRawTxWithHW = ({onConfirm}: Props) => {
const [transportType, setTransportType] = useState<TransportType>('USB')
const [step, setStep] = useState<Step>('select-transport')
const wallet = useSelectedWallet()
Expand All @@ -26,13 +26,13 @@ export const ConfirmRawTxWithHW = ({onSuccess}: Props) => {

const onConnectBLE = async (deviceId: DeviceId) => {
await walletManager.updateHWDeviceInfo(wallet, withBLE(wallet, deviceId))
onSuccess?.({useUSB: false})
onConfirm?.({useUSB: false})
setStep('loading')
}

const onConnectUSB = async (deviceObj: DeviceObj) => {
await walletManager.updateHWDeviceInfo(wallet, withUSB(wallet, deviceObj))
onSuccess?.({useUSB: true})
onConfirm?.({useUSB: true})
setStep('loading')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const OpenOrders = () => {
swapNavigation.submittedTx()
}

const onRawTxHwConfirm = async ({useUSB = false, orderId}: {useUSB?: boolean; orderId: string}) => {
const onRawTxHwConfirm = async ({useUSB, orderId}: {useUSB: boolean; orderId: string}) => {
try {
const order = normalizedOrders.find((o) => o.id === orderId)
if (!order || order.owner === undefined || order.utxo === undefined) return
Expand Down Expand Up @@ -162,7 +162,7 @@ export const OpenOrders = () => {
content: (
<ConfirmRawTx
onConfirm={(rootKey) => onRawTxConfirm(rootKey, id)}
onHWConfirm={() => onRawTxHwConfirm({useUSB: false, orderId: id})}
onHWConfirm={({useUSB}) => onRawTxHwConfirm({useUSB, orderId: id})}
/>
),
height: 400,
Expand Down

0 comments on commit e6dc7b9

Please sign in to comment.