From 7d0353ede23db571413492556a2afe61f137ed4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 29 Aug 2018 12:05:27 +0200 Subject: [PATCH] Latest bridgestream work --- package.json | 2 +- src/bridge/index.js | 1 + src/components/QRCodeExporter.js | 34 ++++++++++------------------- src/components/base/QRCode/index.js | 1 + yarn.lock | 6 ++--- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 383b7ce3..c72c448c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@ledgerhq/hw-transport": "^4.13.0", "@ledgerhq/hw-transport-node-hid": "4.22.0", "@ledgerhq/ledger-core": "2.0.0-rc.6", - "@ledgerhq/live-common": "3.0.2", + "@ledgerhq/live-common": "3.2.3", "animated": "^0.2.2", "async": "^2.6.1", "axios": "^0.18.0", diff --git a/src/bridge/index.js b/src/bridge/index.js index d2d470da..2fdabe04 100644 --- a/src/bridge/index.js +++ b/src/bridge/index.js @@ -12,6 +12,7 @@ const perFamily = { bitcoin: LibcoreBridge, ripple: RippleJSBridge, ethereum: EthereumJSBridge, + stellar: null, } if (USE_MOCK_DATA) { const mockBridge = makeMockBridge() diff --git a/src/components/QRCodeExporter.js b/src/components/QRCodeExporter.js index 2fc2d14e..57933e31 100644 --- a/src/components/QRCodeExporter.js +++ b/src/components/QRCodeExporter.js @@ -1,31 +1,21 @@ // @flow import React, { PureComponent } from 'react' - +import { createSelector } from 'reselect' import { connect } from 'react-redux' -import type { State } from 'reducers' + import { accountsSelector } from 'reducers/accounts' +import { makeChunks } from '@ledgerhq/live-common/lib/bridgestream/exporter' import QRCode from './base/QRCode' -// encode the app state to export into an array of chunks for the mobile app to understand. -// returned data frames are json stringified array with format: [ datalength, index, type, ...rest ] -// NB as soon as we have common types we'll move this in a ledgerhq/common project -function makeChunks(state: State): Array { - const chunksFormatVersion = 1 - const desktopVersion = __APP_VERSION__ - const data = [ - ['meta', chunksFormatVersion, 'desktop', desktopVersion], - ...accountsSelector(state).map(account => [ - 'account', - account.id, - account.name, - account.currency.id, - ]), - ] - return data.map((arr, i) => JSON.stringify([data.length, i, ...arr])) -} - -const mapStateToProps = (state: State) => ({ chunks: makeChunks(state) }) +const mapStateToProps = createSelector(accountsSelector, accounts => ({ + chunks: makeChunks({ + accounts, + exporterName: 'desktop', + exporterVersion: __APP_VERSION__, + pad: true, + }), +})) class QRCodeExporter extends PureComponent< { @@ -38,7 +28,7 @@ class QRCodeExporter extends PureComponent< }, > { static defaultProps = { - fps: 10, + fps: 4, size: 480, } diff --git a/src/components/base/QRCode/index.js b/src/components/base/QRCode/index.js index c92fae38..ff7ae776 100644 --- a/src/components/base/QRCode/index.js +++ b/src/components/base/QRCode/index.js @@ -28,6 +28,7 @@ class QRCode extends PureComponent { qrcode.toCanvas(this._canvas, data, { width: size, margin: 0, + errorCorrectionLevel: 'Q', color: { light: '#ffffff00', // transparent background }, diff --git a/yarn.lock b/yarn.lock index 1fd573ce..d869516d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1549,9 +1549,9 @@ npm "^5.7.1" prebuild-install "^2.2.2" -"@ledgerhq/live-common@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.0.2.tgz#1ee5fcc6044c5a049c067978d81892f79789863c" +"@ledgerhq/live-common@3.2.3": + version "3.2.3" + resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.2.3.tgz#24853f89548f68dc55bde956eb8e2e0d580ee340" dependencies: axios "^0.18.0" bignumber.js "^7.2.1"