From d47a4e099922117b9956081ea76e2e0e1287e143 Mon Sep 17 00:00:00 2001 From: "Valentin D. Pinkman" Date: Mon, 18 Jun 2018 18:13:47 +0200 Subject: [PATCH] removed calls to createSocketDialog for the new createDeviceSocket --- src/components/Workflow/index.js | 1 + src/helpers/apps/installApp.js | 9 ++++++--- src/helpers/apps/uninstallApp.js | 9 ++++++--- src/helpers/devices/getIsGenuine.js | 16 ++++++++++------ src/helpers/firmware/installFinalFirmware.js | 13 ++++++++----- src/helpers/firmware/installMcu.js | 3 ++- src/helpers/firmware/installOsuFirmware.js | 9 ++++++--- 7 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/components/Workflow/index.js b/src/components/Workflow/index.js index 794fa7f6..0fe0cbbf 100644 --- a/src/components/Workflow/index.js +++ b/src/components/Workflow/index.js @@ -53,6 +53,7 @@ class Workflow extends PureComponent { {(device: Device) => ( {(deviceInfo: ?DeviceInfo, dashboardError: ?Error) => { + console.log('deviceInfo', deviceInfo) if (deviceInfo && deviceInfo.mcu && renderMcuUpdate) { return renderMcuUpdate(device, deviceInfo) diff --git a/src/helpers/apps/installApp.js b/src/helpers/apps/installApp.js index 1998cfb5..89373c42 100644 --- a/src/helpers/apps/installApp.js +++ b/src/helpers/apps/installApp.js @@ -1,8 +1,10 @@ // @flow - +import qs from 'qs' import type Transport from '@ledgerhq/hw-transport' -import { createSocketDialog } from 'helpers/common' +import { BASE_SOCKET_URL } from 'helpers/constants' +import { createDeviceSocket } from 'helpers/socket' + import type { LedgerScriptParams } from 'helpers/common' /** @@ -12,5 +14,6 @@ export default async function installApp( transport: Transport<*>, { appParams }: { appParams: LedgerScriptParams }, ): Promise<*> { - return createSocketDialog(transport, '/install', appParams) + const url = `${BASE_SOCKET_URL}/install?${qs.stringify(appParams)}` + return createDeviceSocket(transport, url).toPromise() } diff --git a/src/helpers/apps/uninstallApp.js b/src/helpers/apps/uninstallApp.js index c67c029c..113cd29c 100644 --- a/src/helpers/apps/uninstallApp.js +++ b/src/helpers/apps/uninstallApp.js @@ -1,8 +1,10 @@ // @flow - +import qs from 'qs' import type Transport from '@ledgerhq/hw-transport' -import { createSocketDialog } from 'helpers/common' +import { BASE_SOCKET_URL } from 'helpers/constants' +import { createDeviceSocket } from 'helpers/socket' + import type { LedgerScriptParams } from 'helpers/common' /** @@ -17,5 +19,6 @@ export default async function uninstallApp( firmware: appParams.delete, firmwareKey: appParams.deleteKey, } - return createSocketDialog(transport, '/install', params) + const url = `${BASE_SOCKET_URL}/install?${qs.stringify(params)}` + return createDeviceSocket(transport, url).toPromise() } diff --git a/src/helpers/devices/getIsGenuine.js b/src/helpers/devices/getIsGenuine.js index ad82420f..6e500142 100644 --- a/src/helpers/devices/getIsGenuine.js +++ b/src/helpers/devices/getIsGenuine.js @@ -1,12 +1,16 @@ // @flow +import qs from 'qs' import type Transport from '@ledgerhq/hw-transport' -import { createSocketDialog } from 'helpers/common' -import { SKIP_GENUINE } from 'config/constants' +import { SKIP_GENUINE, MANAGER_API_BASE } from 'config/constants' + +import { createDeviceSocket } from 'helpers/socket' export default async ( transport: Transport<*>, - { targetId }: { targetId: string | number }, -): Promise => - SKIP_GENUINE + params: { targetId: string | number }, +): Promise => { + const url = `${MANAGER_API_BASE}/genuine?${qs.stringify(params)}` + return SKIP_GENUINE ? new Promise(resolve => setTimeout(() => resolve('0000'), 1000)) - : createSocketDialog(transport, '/genuine', { targetId }, true) + : createDeviceSocket(transport, url).toPromise() +} diff --git a/src/helpers/firmware/installFinalFirmware.js b/src/helpers/firmware/installFinalFirmware.js index 43a57435..9247646d 100644 --- a/src/helpers/firmware/installFinalFirmware.js +++ b/src/helpers/firmware/installFinalFirmware.js @@ -1,18 +1,21 @@ // @flow - +import qs from 'qs' import type Transport from '@ledgerhq/hw-transport' -import { createSocketDialog, buildParamsFromFirmware } from 'helpers/common' +import { BASE_SOCKET_URL } from 'helpers/constants' +import { createDeviceSocket } from 'helpers/socket' +import { buildParamsFromFirmware } from 'helpers/common' type Input = Object type Result = * -const buildOsuParams = buildParamsFromFirmware('final') +const buildFinalParams = buildParamsFromFirmware('final') export default async (transport: Transport<*>, firmware: Input): Result => { try { - const osuData = buildOsuParams(firmware) - await createSocketDialog(transport, '/install', osuData) + const finalData = buildFinalParams(firmware) + const url = `${BASE_SOCKET_URL}/install?${qs.stringify(finalData)}` + await createDeviceSocket(transport, url).toPromise() return { success: true } } catch (err) { const error = Error(err.message) diff --git a/src/helpers/firmware/installMcu.js b/src/helpers/firmware/installMcu.js index 3a0b6499..bb9a9d81 100644 --- a/src/helpers/firmware/installMcu.js +++ b/src/helpers/firmware/installMcu.js @@ -1,6 +1,7 @@ // @flow -import type Transport from '@ledgerhq/hw-transport' import qs from 'qs' +import type Transport from '@ledgerhq/hw-transport' + import { MANAGER_API_URL } from 'helpers/constants' import { createDeviceSocket } from 'helpers/socket' diff --git a/src/helpers/firmware/installOsuFirmware.js b/src/helpers/firmware/installOsuFirmware.js index c213cb58..24c26b91 100644 --- a/src/helpers/firmware/installOsuFirmware.js +++ b/src/helpers/firmware/installOsuFirmware.js @@ -1,8 +1,10 @@ // @flow - +import qs from 'qs' import type Transport from '@ledgerhq/hw-transport' -import { createSocketDialog, buildParamsFromFirmware } from 'helpers/common' +import { BASE_SOCKET_URL } from 'helpers/constants' +import { createDeviceSocket } from 'helpers/socket' +import { buildParamsFromFirmware } from 'helpers/common' type Input = Object @@ -13,7 +15,8 @@ const buildOsuParams = buildParamsFromFirmware('osu') export default async (transport: Transport<*>, firmware: Input): Result => { try { const osuData = buildOsuParams(firmware) - await createSocketDialog(transport, '/install', osuData) + const url = `${BASE_SOCKET_URL}/install?${qs.stringify(osuData)}` + await createDeviceSocket(transport, url).toPromise() return { success: true } } catch (err) { const error = Error(err.message)