Browse Source

Merge pull request #1469 from gre/bridgestream-aug18

Latest bridgestream work
master
Gaëtan Renaudeau 6 years ago
committed by GitHub
parent
commit
248ea0da3c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 1
      src/bridge/index.js
  3. 34
      src/components/QRCodeExporter.js
  4. 1
      src/components/base/QRCode/index.js
  5. 6
      yarn.lock

2
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",

1
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()

34
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<string> {
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,
}

1
src/components/base/QRCode/index.js

@ -28,6 +28,7 @@ class QRCode extends PureComponent<Props> {
qrcode.toCanvas(this._canvas, data, {
width: size,
margin: 0,
errorCorrectionLevel: 'Q',
color: {
light: '#ffffff00', // transparent background
},

6
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"

Loading…
Cancel
Save