Browse Source

Merge pull request #1309 from valpinkman/explicit-params

removed unwanted params for GET http calls, also removed helpers/common
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
0ff2aa618f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/commands/installApp.js
  2. 2
      src/commands/uninstallApp.js
  3. 2
      src/components/ManagerPage/AppSearchBar.js
  4. 2
      src/components/ManagerPage/AppsList.js
  5. 2
      src/components/ManagerPage/FirmwareUpdate.js
  6. 2
      src/components/modals/UpdateFirmware/index.js
  7. 9
      src/helpers/apps/installApp.js
  8. 6
      src/helpers/apps/uninstallApp.js
  9. 2
      src/helpers/devices/getDeviceInfo.js
  10. 2
      src/helpers/devices/getMemInfo.js
  11. 2
      src/helpers/devices/isDashboardOpen.js
  12. 16
      src/helpers/firmware/getFirmwareInfo.js
  13. 14
      src/helpers/types.js
  14. 2
      src/helpers/urls.js

2
src/commands/installApp.js

@ -6,7 +6,7 @@ import { fromPromise } from 'rxjs/observable/fromPromise'
import { withDevice } from 'helpers/deviceAccess'
import installApp from 'helpers/apps/installApp'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
type Input = {
app: LedgerScriptParams,

2
src/commands/uninstallApp.js

@ -6,7 +6,7 @@ import { withDevice } from 'helpers/deviceAccess'
import uninstallApp from 'helpers/apps/uninstallApp'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
type Input = {
app: LedgerScriptParams,

2
src/components/ManagerPage/AppSearchBar.js

@ -3,7 +3,7 @@
import React, { PureComponent, Fragment } from 'react'
import styled from 'styled-components'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
import Box from 'components/base/Box'
import Space from 'components/base/Space'

2
src/components/ManagerPage/AppsList.js

@ -7,7 +7,7 @@ import { translate } from 'react-i18next'
import { connect } from 'react-redux'
import { compose } from 'redux'
import type { Device, T } from 'types/common'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
import type { DeviceInfo } from 'helpers/devices/getDeviceInfo'
import { developerModeSelector } from 'reducers/settings'

2
src/components/ManagerPage/FirmwareUpdate.js

@ -9,7 +9,7 @@ import invariant from 'invariant'
import type { Device, T } from 'types/common'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
import type { StepId } from 'components/modals/UpdateFirmware'
import getLatestFirmwareForDevice from 'commands/getLatestFirmwareForDevice'

2
src/components/modals/UpdateFirmware/index.js

@ -10,7 +10,7 @@ import SyncSkipUnderPriority from 'components/SyncSkipUnderPriority'
import type { StepProps as DefaultStepProps, Step } from 'components/base/Stepper'
import type { ModalStatus } from 'components/ManagerPage/FirmwareUpdate'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
import { FreezeDeviceChangeEvents } from '../../ManagerPage/HookDeviceChange'
import StepFullFirmwareInstall from './steps/01-step-install-full-firmware'

9
src/helpers/apps/installApp.js

@ -5,9 +5,9 @@ import type Transport from '@ledgerhq/hw-transport'
import { BASE_SOCKET_URL } from 'config/constants'
import { createDeviceSocket } from 'helpers/socket'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
import { createCustomErrorClass } from '../errors'
import { createCustomErrorClass } from 'helpers/errors'
const ManagerNotEnoughSpaceError = createCustomErrorClass('ManagerNotEnoughSpace')
const ManagerDeviceLockedError = createCustomErrorClass('ManagerDeviceLocked')
@ -41,8 +41,11 @@ export default async function installApp(
): Promise<*> {
const params = {
targetId,
...app,
perso: app.perso,
deleteKey: app.delete_key,
firmware: app.firmware,
firmwareKey: app.firmware_key,
hash: app.hash,
}
const url = `${BASE_SOCKET_URL}/install?${qs.stringify(params)}`
return remapError(createDeviceSocket(transport, url).toPromise())

6
src/helpers/apps/uninstallApp.js

@ -5,7 +5,7 @@ import type Transport from '@ledgerhq/hw-transport'
import { BASE_SOCKET_URL } from 'config/constants'
import { createDeviceSocket } from 'helpers/socket'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
import { createCustomErrorClass } from '../errors'
const ManagerDeviceLockedError = createCustomErrorClass('ManagerDeviceLocked')
@ -34,9 +34,11 @@ export default async function uninstallApp(
): Promise<*> {
const params = {
targetId,
...app,
perso: app.perso,
deleteKey: app.delete_key,
firmware: app.delete,
firmwareKey: app.delete_key,
hash: app.hash,
}
const url = `${BASE_SOCKET_URL}/install?${qs.stringify(params)}`
return remapError(createDeviceSocket(transport, url).toPromise())

2
src/helpers/devices/getDeviceInfo.js

@ -2,7 +2,7 @@
import type Transport from '@ledgerhq/hw-transport'
import { getFirmwareInfo } from 'helpers/common'
import getFirmwareInfo from 'helpers/firmware/getFirmwareInfo'
import { FORCE_PROVIDER } from 'config/constants'
export type DeviceInfo = {

2
src/helpers/devices/getMemInfo.js

@ -2,7 +2,7 @@
import type Transport from '@ledgerhq/hw-transport'
import { getFirmwareInfo } from 'helpers/common'
import getFirmwareInfo from 'helpers/firmware/getFirmwareInfo'
export default async function getMemInfos(transport: Transport<*>): Promise<Object> {
const { targetId } = await getFirmwareInfo(transport) // eslint-disable-line

2
src/helpers/devices/isDashboardOpen.js

@ -2,7 +2,7 @@
import type Transport from '@ledgerhq/hw-transport'
import { getFirmwareInfo } from 'helpers/common'
import getFirmwareInfo from 'helpers/firmware/getFirmwareInfo'
type Result = boolean

16
src/helpers/common.js → src/helpers/firmware/getFirmwareInfo.js

@ -1,6 +1,5 @@
// @flow
// FIXME remove this file! 'helpers/common.js' RLY? :P
import type Transport from '@ledgerhq/hw-transport'
const APDUS = {
@ -10,23 +9,10 @@ const APDUS = {
GET_FIRMWARE_FALLBACK: [0xe0, 0xc4, 0x00, 0x00],
}
export type LedgerScriptParams = {
firmware?: string,
firmware_key?: string,
delete?: string,
delete_key?: string,
targetId?: string | number,
name: string,
version: string,
icon: string,
app?: number,
hash?: string,
}
/**
* Retrieve targetId and firmware version from device
*/
export async function getFirmwareInfo(transport: Transport<*>) {
export default async function getFirmwareInfo(transport: Transport<*>) {
const res = await transport.send(...APDUS.GET_FIRMWARE)
const byteArray = [...res]
const data = byteArray.slice(0, byteArray.length - 2)

14
src/helpers/types.js

@ -0,0 +1,14 @@
// @flow
export type LedgerScriptParams = {
firmware?: string,
firmware_key?: string,
delete?: string,
delete_key?: string,
targetId?: string | number,
name: string,
version: string,
icon: string,
app?: number,
hash?: string,
perso?: string,
}

2
src/helpers/urls.js

@ -2,7 +2,7 @@
import qs from 'qs'
import { MANAGER_API_BASE, BASE_SOCKET_URL } from 'config/constants'
import type { LedgerScriptParams } from 'helpers/common'
import type { LedgerScriptParams } from 'helpers/types'
const urlBuilder = (base: string) => (endpoint: string): string => `${base}/${endpoint}`

Loading…
Cancel
Save