Browse Source

use new production api (temporary url) for commands

master
Valentin D. Pinkman 7 years ago
parent
commit
cdc018bd34
No known key found for this signature in database GPG Key ID: E7D110669FFB8D3E
  1. 11
      src/commands/listApps.js
  2. 6
      src/components/ManagerPage/AppsList.js
  3. 16
      src/helpers/apps/listApps.js
  4. 1
      src/helpers/constants.js
  5. 2
      src/helpers/devices/getFirmwareInfo.js
  6. 3
      src/helpers/devices/getLatestFirmwareForDevice.js

11
src/commands/listApps.js

@ -5,15 +5,14 @@ import { fromPromise } from 'rxjs/observable/fromPromise'
import listApps from 'helpers/apps/listApps'
// type Input = {
// targetId: string | number,
// }
type Input = {
targetId: string | number,
}
type Input = *
type Result = *
const cmd: Command<Input, Result> = createCommand('listApps', () =>
/* { targetId } */ fromPromise(listApps(/* targetId */)),
const cmd: Command<Input, Result> = createCommand('listApps', ({ targetId }) =>
fromPromise(listApps(targetId)),
)
export default cmd

6
src/components/ManagerPage/AppsList.js

@ -46,7 +46,7 @@ type LedgerApp = {
type Props = {
device: Device,
// targetId: string | number,
targetId: string | number,
t: T,
}
@ -75,8 +75,8 @@ class AppsList extends PureComponent<Props, State> {
async fetchAppList() {
try {
// const { targetId } = this.props // TODO: REUSE THIS WHEN SERVER IS UP
const appsList = CACHED_APPS || (await listApps.send().toPromise())
const { targetId } = this.props
const appsList = CACHED_APPS || (await listApps.send({ targetId }).toPromise())
CACHED_APPS = appsList
if (!this._unmounted) {
this.setState({ appsList, status: 'idle' })

16
src/helpers/apps/listApps.js

@ -1,18 +1,18 @@
// @flow
import axios from 'axios'
// const { API_BASE_URL } = process.env
import { API_BASE_URL } from 'helpers/constants'
export default async (/* targetId: string | number */) => {
export default async (targetId: string | number) => {
try {
// const { data: deviceData } = await axios.get(
// `${API_BASE_URL}/device_versions_target_id/${targetId}`,
// )
const { data: deviceData } = await axios.get(
`${API_BASE_URL}/device_versions_target_id/${targetId}`,
)
const { data } = await axios.get('https://api.ledgerwallet.com/update/applications')
// if (deviceData.name in data) {
// return data[deviceData.name]
// }
if (deviceData.name in data) {
return data[deviceData.name]
}
return data['nanos-1.4']
} catch (err) {

1
src/helpers/constants.js

@ -2,6 +2,7 @@
export const BASE_SOCKET_URL = 'ws://api.ledgerwallet.com'
export const BASE_SOCKET_URL_TEMP = 'ws://manager.ledger.fr:3500'
export const API_BASE_URL = process.env.API_BASE_URL || 'https://beta.manager.live.ledger.fr/api'
// If you want to test locally with https://github.com/LedgerHQ/ledger-update-python-api
// export const BASE_SOCKET_URL = 'ws://localhost:3001/update'

2
src/helpers/devices/getFirmwareInfo.js

@ -2,7 +2,7 @@
import axios from 'axios'
import isEmpty from 'lodash/isEmpty'
const { API_BASE_URL } = process.env
import { API_BASE_URL } from 'helpers/constants'
type Input = {
version: string,

3
src/helpers/devices/getLatestFirmwareForDevice.js

@ -1,11 +1,10 @@
// @flow
import axios from 'axios'
import isEmpty from 'lodash/isEmpty'
import { API_BASE_URL } from 'helpers/constants'
import getFirmwareInfo from './getFirmwareInfo'
const { API_BASE_URL } = process.env
type Input = {
targetId: string | number,
version: string,

Loading…
Cancel
Save