diff --git a/src/commands/getIsGenuine.js b/src/commands/getIsGenuine.js
index 25f94d13..8b9cfa2e 100644
--- a/src/commands/getIsGenuine.js
+++ b/src/commands/getIsGenuine.js
@@ -4,10 +4,13 @@ import { createCommand, Command } from 'helpers/ipc'
import { fromPromise } from 'rxjs/observable/fromPromise'
import getIsGenuine from 'helpers/devices/getIsGenuine'
+import { withDevice } from 'helpers/deviceAccess'
type Input = *
-type Result = boolean
+type Result = string
-const cmd: Command = createCommand('getIsGenuine', () => fromPromise(getIsGenuine()))
+const cmd: Command = createCommand('getIsGenuine', ({ devicePath, targetId }) =>
+ fromPromise(withDevice(devicePath)(transport => getIsGenuine(transport, { targetId }))),
+)
export default cmd
diff --git a/src/components/ManagerPage/EnsureGenuine.js b/src/components/ManagerPage/EnsureGenuine.js
index 2de56aeb..1391e163 100644
--- a/src/components/ManagerPage/EnsureGenuine.js
+++ b/src/components/ManagerPage/EnsureGenuine.js
@@ -12,8 +12,14 @@ type Error = {
stack: string,
}
+type DeviceInfos = {
+ targetId: number | string,
+ version: string,
+}
+
type Props = {
device: ?Device,
+ infos: ?DeviceInfos,
children: (isGenuine: ?boolean, error: ?Error) => Node,
}
@@ -49,12 +55,15 @@ class EnsureGenuine extends PureComponent {
_unmounting = false
async checkIsGenuine() {
- const { device } = this.props
- if (device && !this._checking) {
+ const { device, infos } = this.props
+ if (device && infos && !this._checking) {
this._checking = true
try {
- const isGenuine = await getIsGenuine.send().toPromise()
- if (!this.state.genuine || this.state.error) {
+ const res = await getIsGenuine
+ .send({ devicePath: device.path, targetId: infos.targetId })
+ .toPromise()
+ const isGenuine = res === '0000'
+ if ((!this.state.genuine || this.state.error) && isGenuine) {
!this._unmounting && this.setState({ genuine: isGenuine, error: null })
}
} catch (err) {
diff --git a/src/components/ManagerPage/Workflow.js b/src/components/ManagerPage/Workflow.js
index 1b42771f..e52f701a 100644
--- a/src/components/ManagerPage/Workflow.js
+++ b/src/components/ManagerPage/Workflow.js
@@ -52,7 +52,7 @@ class Workflow extends PureComponent {
{(device: Device) => (
{(deviceInfo: ?DeviceInfo, dashboardError: ?Error) => (
-
+
{(isGenuine: ?boolean, genuineError: ?Error) => {
if (dashboardError || genuineError) {
return renderError
diff --git a/src/helpers/apps/installApp.js b/src/helpers/apps/installApp.js
index 465dc18f..2cdd04a3 100644
--- a/src/helpers/apps/installApp.js
+++ b/src/helpers/apps/installApp.js
@@ -12,5 +12,5 @@ export default async function installApp(
transport: Transport<*>,
{ appParams }: { appParams: LedgerScriptParams },
): Promise {
- return createSocketDialog(transport, '/update/install', appParams)
+ return createSocketDialog(transport, '/install', appParams)
}
diff --git a/src/helpers/apps/uninstallApp.js b/src/helpers/apps/uninstallApp.js
index af3c23b2..c9f4fc44 100644
--- a/src/helpers/apps/uninstallApp.js
+++ b/src/helpers/apps/uninstallApp.js
@@ -17,5 +17,5 @@ export default async function uninstallApp(
firmware: appParams.delete,
firmwareKey: appParams.deleteKey,
}
- return createSocketDialog(transport, '/update/install', params)
+ return createSocketDialog(transport, '/install', params)
}
diff --git a/src/helpers/common.js b/src/helpers/common.js
index 52ebbe06..7d96e48b 100644
--- a/src/helpers/common.js
+++ b/src/helpers/common.js
@@ -5,7 +5,7 @@ import Websocket from 'ws'
import qs from 'qs'
import type Transport from '@ledgerhq/hw-transport'
-import { BASE_SOCKET_URL, APDUS } from './constants'
+import { BASE_SOCKET_URL, APDUS, MANAGER_API_URL } from './constants'
type WebsocketType = {
send: (string, any) => void,
@@ -24,34 +24,11 @@ export type LedgerScriptParams = {
firmwareKey?: string,
delete?: string,
deleteKey?: string,
+ targetId?: string | number,
}
type FirmwareUpdateType = 'osu' | 'final'
-// /**
-// * Install an app on the device
-// */
-// export async function installApp(
-// transport: Transport<*>,
-// { appParams }: { appParams: LedgerScriptParams },
-// ): Promise {
-// return createSocketDialog(transport, '/update/install', appParams)
-// }
-
-/**
- * Uninstall an app on the device
- */
-export async function uninstallApp(
- transport: Transport<*>,
- { appParams }: { appParams: LedgerScriptParams },
-): Promise {
- return createSocketDialog(transport, '/update/install', {
- ...appParams,
- firmware: appParams.delete,
- firmwareKey: appParams.deleteKey,
- })
-}
-
export async function getMemInfos(transport: Transport<*>): Promise