diff --git a/src/commands/installOsuFirmware.js b/src/commands/installOsuFirmware.js
index f5110b13..8d4a6f4f 100644
--- a/src/commands/installOsuFirmware.js
+++ b/src/commands/installOsuFirmware.js
@@ -2,8 +2,8 @@
import { createCommand, Command } from 'helpers/ipc'
import { fromPromise } from 'rxjs/observable/fromPromise'
-import { withDevice } from 'helpers/deviceAccess'
+import { withDevice } from 'helpers/deviceAccess'
import installOsuFirmware from 'helpers/firmware/installOsuFirmware'
type Input = {
diff --git a/src/commands/listApps.js b/src/commands/listApps.js
index a6659cb4..68831174 100644
--- a/src/commands/listApps.js
+++ b/src/commands/listApps.js
@@ -3,13 +3,16 @@
import { createCommand, Command } from 'helpers/ipc'
import { fromPromise } from 'rxjs/observable/fromPromise'
+import { withDevice } from 'helpers/deviceAccess'
import listApps from 'helpers/apps/listApps'
-type Input = *
+type Input = {
+ devicePath: string,
+}
type Result = *
-const cmd: Command = createCommand('manager', 'listApps', () =>
- fromPromise(listApps()),
+const cmd: Command = createCommand('devices', 'listApps', ({ devicePath }) =>
+ fromPromise(withDevice(devicePath)(transport => listApps(transport))),
)
export default cmd
diff --git a/src/components/ManagerPage/AppsList.js b/src/components/ManagerPage/AppsList.js
index 66d8dd88..279ddf0f 100644
--- a/src/components/ManagerPage/AppsList.js
+++ b/src/components/ManagerPage/AppsList.js
@@ -69,10 +69,17 @@ class AppsList extends PureComponent {
_unmounted = false
async fetchAppList() {
- const appsList = CACHED_APPS || (await listApps.send().toPromise())
- CACHED_APPS = appsList
- if (!this._unmounted) {
- this.setState({ appsList, status: 'idle' })
+ try {
+ const {
+ device: { path: devicePath },
+ } = this.props
+ const appsList = CACHED_APPS || (await listApps.send({ devicePath }).toPromise())
+ CACHED_APPS = appsList
+ if (!this._unmounted) {
+ this.setState({ appsList, status: 'idle' })
+ }
+ } catch (err) {
+ this.setState({ status: 'error', error: err.message })
}
}
diff --git a/src/components/ManagerPage/index.js b/src/components/ManagerPage/index.js
index 88d5b9b7..0e1c616a 100644
--- a/src/components/ManagerPage/index.js
+++ b/src/components/ManagerPage/index.js
@@ -1,8 +1,9 @@
// @flow
-import React, { Component, Fragment } from 'react'
+import React, { Fragment } from 'react'
import { translate } from 'react-i18next'
+import type { Node } from 'react'
import type { T } from 'types/common'
import AppsList from './AppsList'
@@ -16,44 +17,35 @@ type Props = {
t: T,
}
-type State = {}
-
-class ManagerPage extends Component {
- render() {
- const { t } = this.props
-
- return (
-
-
- {device => (
-
- {deviceInfo => (
-
- {deviceInfo.mcu && bootloader mode}
- {deviceInfo.final && osu mode}
-
- {!deviceInfo.mcu &&
- !deviceInfo.final && (
-
-
-
-
- )}
-
- )}
-
+const ManagerPage = ({ t }: Props): Node => (
+
+
+ {device => (
+
+ {deviceInfo => (
+
+ {deviceInfo.mcu && bootloader mode}
+ {deviceInfo.final && osu mode}
+
+ {!deviceInfo.mcu &&
+ !deviceInfo.final && (
+
+
+
+
+ )}
+
)}
-
-
- )
- }
-}
-
+
+ )}
+
+
+)
export default translate()(ManagerPage)
diff --git a/src/helpers/apps/listApps.js b/src/helpers/apps/listApps.js
index dce2b9e3..50f73837 100644
--- a/src/helpers/apps/listApps.js
+++ b/src/helpers/apps/listApps.js
@@ -1,10 +1,23 @@
// @flow
-
import axios from 'axios'
+import type Transport from '@ledgerhq/hw-transport'
+
+import { getFirmwareInfo } from 'helpers/common'
+
+const { API_BASE_URL } = process.env
-export default async () => {
+export default async (transport: Transport<*>) => {
try {
+ const { targetId } = await getFirmwareInfo(transport)
+ const { data: deviceData } = await axios.get(
+ `${API_BASE_URL}/device_versions_target_id/${targetId}`,
+ )
const { data } = await axios.get('https://api.ledgerwallet.com/update/applications')
+
+ if (deviceData.name in data) {
+ return data[deviceData.name]
+ }
+
return data['nanos-1.4']
} catch (err) {
const error = Error(err.message)
diff --git a/src/internals/devices/index.js b/src/internals/devices/index.js
index 7500c00a..4f830a2e 100644
--- a/src/internals/devices/index.js
+++ b/src/internals/devices/index.js
@@ -15,6 +15,7 @@ import uninstallApp from 'commands/uninstallApp'
import installOsuFirmware from 'commands/installOsuFirmware'
import installFinalFirmware from 'commands/installFinalFirmware'
import installMcu from 'commands/installMcu'
+import listApps from 'commands/listApps'
export const commands: Array> = [
getAddress,
@@ -31,4 +32,5 @@ export const commands: Array> = [
installOsuFirmware,
installFinalFirmware,
installMcu,
+ listApps,
]
diff --git a/src/internals/manager/index.js b/src/internals/manager/index.js
index 7f7a94af..cb51bae3 100644
--- a/src/internals/manager/index.js
+++ b/src/internals/manager/index.js
@@ -1,7 +1,6 @@
// @flow
import type { Command } from 'helpers/ipc'
-import listApps from 'commands/listApps'
import getMemInfo from 'commands/getMemInfo'
/**
@@ -20,4 +19,4 @@ import getMemInfo from 'commands/getMemInfo'
*
*/
-export const commands: Array> = [listApps, getMemInfo]
+export const commands: Array> = [getMemInfo]