Browse Source
removed calls to createSocketDialog for the new createDeviceSocket
master
Valentin D. Pinkman
7 years ago
No known key found for this signature in database
GPG Key ID: E7D110669FFB8D3E
7 changed files with
39 additions and
21 deletions
-
src/components/Workflow/index.js
-
src/helpers/apps/installApp.js
-
src/helpers/apps/uninstallApp.js
-
src/helpers/devices/getIsGenuine.js
-
src/helpers/firmware/installFinalFirmware.js
-
src/helpers/firmware/installMcu.js
-
src/helpers/firmware/installOsuFirmware.js
|
|
@ -53,6 +53,7 @@ class Workflow extends PureComponent<Props, State> { |
|
|
|
{(device: Device) => ( |
|
|
|
<EnsureDashboard device={device}> |
|
|
|
{(deviceInfo: ?DeviceInfo, dashboardError: ?Error) => { |
|
|
|
console.log('deviceInfo', deviceInfo) |
|
|
|
|
|
|
|
if (deviceInfo && deviceInfo.mcu && renderMcuUpdate) { |
|
|
|
return renderMcuUpdate(device, deviceInfo) |
|
|
|
|
|
@ -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() |
|
|
|
} |
|
|
|
|
|
@ -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() |
|
|
|
} |
|
|
|
|
|
@ -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<string> => |
|
|
|
SKIP_GENUINE |
|
|
|
params: { targetId: string | number }, |
|
|
|
): Promise<string> => { |
|
|
|
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() |
|
|
|
} |
|
|
|
|
|
@ -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) |
|
|
|
|
|
@ -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' |
|
|
|
|
|
|
|
|
|
@ -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) |
|
|
|