Valentin D. Pinkman
7 years ago
5 changed files with 108 additions and 51 deletions
@ -0,0 +1,48 @@ |
|||
// @flow
|
|||
import React, { PureComponent } from 'react' |
|||
|
|||
import type { Device } from 'types/common' |
|||
import installMcu from 'commands/installMcu' |
|||
|
|||
type DeviceInfo = { |
|||
targetId: number | string, |
|||
version: string, |
|||
final: boolean, |
|||
mcu: boolean, |
|||
} |
|||
|
|||
type Props = { |
|||
device: Device, |
|||
deviceInfo: DeviceInfo, |
|||
} |
|||
|
|||
type State = { |
|||
flashing: boolean, |
|||
} |
|||
|
|||
class FlashMcu extends PureComponent<Props, State> { |
|||
state = { |
|||
flashing: false, |
|||
} |
|||
|
|||
componentDidMount() { |
|||
this.flasMCU() |
|||
} |
|||
|
|||
flasMCU = async () => { |
|||
const { device, deviceInfo } = this.props |
|||
const { flashing } = this.state |
|||
|
|||
if (!flashing) { |
|||
this.setState(state => ({ ...state, flashing: true })) |
|||
await installMcu.send({ devicePath: device.path, targetId: deviceInfo.targetId }).toPromise() |
|||
this.setState(state => ({ ...state, flashing: false })) |
|||
} |
|||
} |
|||
|
|||
render() { |
|||
return <div>Flashing MCU</div> |
|||
} |
|||
} |
|||
|
|||
export default FlashMcu |
@ -1,8 +1,15 @@ |
|||
// @flow
|
|||
import type Transport from '@ledgerhq/hw-transport' |
|||
import qs from 'qs' |
|||
import { MANAGER_API_URL } from 'helpers/constants' |
|||
import { createDeviceSocket } from 'helpers/socket' |
|||
|
|||
type Result = Promise<boolean> |
|||
type Result = Promise<*> |
|||
|
|||
// TODO: IMPLEMENTATION FOR FLASHING FIRMWARE
|
|||
// GETTING APDUS FROM SERVER
|
|||
// SEND THE APDUS TO DEVICE
|
|||
export default async (): Result => new Promise(resolve => resolve(true)) |
|||
export default async ( |
|||
transport: Transport<*>, |
|||
params: { targetId: string | number, version: string }, |
|||
): Result => { |
|||
const url = `${MANAGER_API_URL}/mcu?${qs.stringify(params)}` |
|||
return createDeviceSocket(transport, url).toPromise() |
|||
} |
|||
|
Loading…
Reference in new issue