Browse Source

removed calls to createSocketDialog for the new createDeviceSocket

master
Valentin D. Pinkman 7 years ago
parent
commit
d47a4e0999
No known key found for this signature in database GPG Key ID: E7D110669FFB8D3E
  1. 1
      src/components/Workflow/index.js
  2. 9
      src/helpers/apps/installApp.js
  3. 9
      src/helpers/apps/uninstallApp.js
  4. 16
      src/helpers/devices/getIsGenuine.js
  5. 13
      src/helpers/firmware/installFinalFirmware.js
  6. 3
      src/helpers/firmware/installMcu.js
  7. 9
      src/helpers/firmware/installOsuFirmware.js

1
src/components/Workflow/index.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)

9
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()
}

9
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()
}

16
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<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()
}

13
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)

3
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'

9
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)

Loading…
Cancel
Save