Browse Source

Merge pull request #1555 from gre/qrstream

New version of QRStream
gre-patch-1
Gaëtan Renaudeau 6 years ago
committed by GitHub
parent
commit
af4f96c27a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 36
      src/components/QRCodeExporter.js
  3. 2
      src/components/base/QRCode/index.js
  4. 11
      src/reducers/settings.js
  5. 14
      yarn.lock

2
package.json

@ -40,7 +40,7 @@
"@ledgerhq/hw-transport": "^4.13.0", "@ledgerhq/hw-transport": "^4.13.0",
"@ledgerhq/hw-transport-node-hid": "4.22.0", "@ledgerhq/hw-transport-node-hid": "4.22.0",
"@ledgerhq/ledger-core": "2.0.0-rc.7", "@ledgerhq/ledger-core": "2.0.0-rc.7",
"@ledgerhq/live-common": "^3.7.1", "@ledgerhq/live-common": "3.8.0",
"animated": "^0.2.2", "animated": "^0.2.2",
"async": "^2.6.1", "async": "^2.6.1",
"axios": "^0.18.0", "axios": "^0.18.0",

36
src/components/QRCodeExporter.js

@ -1,24 +1,28 @@
// @flow // @flow
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import { Buffer } from 'buffer'
import { createSelector } from 'reselect' import { createSelector } from 'reselect'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { accountsSelector } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import { exportSettingsSelector } from 'reducers/settings'
import { makeChunks } from '@ledgerhq/live-common/lib/bridgestream/exporter' import { makeChunks } from '@ledgerhq/live-common/lib/bridgestream/exporter'
import QRCode from './base/QRCode' import QRCode from './base/QRCode'
const mapStateToProps = createSelector(accountsSelector, accounts => ({ const mapStateToProps = createSelector(
chunks: makeChunks({ accountsSelector,
accounts, exportSettingsSelector,
exporterName: 'desktop', (accounts, settings) => ({
exporterVersion: __APP_VERSION__, chunks: makeChunks({
pad: true, accounts,
settings,
exporterName: 'desktop',
exporterVersion: __APP_VERSION__,
chunkSize: 120,
}),
}), }),
})) )
const LOW_FPS = 2
const HIGH_FPS = 8
class QRCodeExporter extends PureComponent< class QRCodeExporter extends PureComponent<
{ {
@ -36,18 +40,16 @@ class QRCodeExporter extends PureComponent<
state = { state = {
frame: 0, frame: 0,
fps: HIGH_FPS, fps: 5,
} }
componentDidMount() { componentDidMount() {
console.log(`BRIDGESTREAM_DATA=${btoa(JSON.stringify(this.props.chunks))}`) // eslint-disable-line const BRIDGESTREAM_DATA = Buffer.from(JSON.stringify(this.props.chunks)).toString('base64')
console.log(`BRIDGESTREAM_DATA=${BRIDGESTREAM_DATA}`) // eslint-disable-line
const nextFrame = ({ frame, fps }, { chunks }) => { const nextFrame = ({ frame }, { chunks }) => {
frame = (frame + 1) % chunks.length frame = (frame + 1) % chunks.length
return { return { frame }
frame,
fps: frame === 0 ? (fps === LOW_FPS ? HIGH_FPS : LOW_FPS) : fps,
}
} }
let lastT let lastT

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

@ -38,7 +38,7 @@ class QRCode extends PureComponent<Props> {
} }
render() { render() {
return <canvas ref={n => (this._canvas = n)} /> return <canvas style={{ cursor: 'none' }} ref={n => (this._canvas = n)} />
} }
} }

11
src/reducers/settings.js

@ -224,4 +224,15 @@ export const selectedTimeRangeSelector = (state: State) => state.settings.select
export const hasCompletedOnboardingSelector = (state: State) => export const hasCompletedOnboardingSelector = (state: State) =>
state.settings.hasCompletedOnboarding state.settings.hasCompletedOnboarding
export const exportSettingsSelector = createSelector(
counterValueCurrencySelector,
counterValueExchangeSelector,
state => state.settings.currenciesSettings,
(counterValueCurrency, counterValueExchange, currenciesSettings) => ({
counterValue: counterValueCurrency.ticker,
counterValueExchange,
currenciesSettings,
}),
)
export default handleActions(handlers, INITIAL_STATE) export default handleActions(handlers, INITIAL_STATE)

14
yarn.lock

@ -1749,15 +1749,16 @@
npm "^5.7.1" npm "^5.7.1"
prebuild-install "^2.2.2" prebuild-install "^2.2.2"
"@ledgerhq/live-common@^3.7.1": "@ledgerhq/live-common@3.8.0":
version "3.7.1" version "3.8.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.7.1.tgz#5ce1895920d2eae6c454c2c72612dc9afd11adec" resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.8.0.tgz#8a956f4995c6006d7788a98959d0b0cab92307f6"
integrity sha512-xlvH6+O1iNC1LI+UyiKb9i4u/6mbO8jTBvXZ6EeFgMhAZGLHNgO2uEJVBxOFe4lVImWqfQI0b8i04AipjlSw6w== integrity sha512-ZfhNP9Zt6LGVJhwIdGqeqUZdele6cWEiGDsuXl5NGxS5BGuFZFp7MfrQ7IQWIaePQ5/A1FMy4SoOkgdPskqtvw==
dependencies: dependencies:
axios "^0.18.0" axios "^0.18.0"
bignumber.js "^7.2.1" bignumber.js "^7.2.1"
invariant "^2.2.2" invariant "^2.2.2"
lodash "^4.17.4" lodash "^4.17.4"
node-lzw "^0.3.1"
numeral "^2.0.6" numeral "^2.0.6"
prando "^3.0.1" prando "^3.0.1"
react "^16.4.0" react "^16.4.0"
@ -11735,6 +11736,11 @@ node-loader@^0.6.0:
resolved "https://registry.yarnpkg.com/node-loader/-/node-loader-0.6.0.tgz#c797ef51095ed5859902b157f6384f6361e05ae8" resolved "https://registry.yarnpkg.com/node-loader/-/node-loader-0.6.0.tgz#c797ef51095ed5859902b157f6384f6361e05ae8"
integrity sha1-x5fvUQle1YWZArFX9jhPY2HgWug= integrity sha1-x5fvUQle1YWZArFX9jhPY2HgWug=
node-lzw@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/node-lzw/-/node-lzw-0.3.1.tgz#f50e37968976aca83320028b91f101df4a436b2d"
integrity sha1-9Q43lol2rKgzIAKLkfEB30pDay0=
node-notifier@^5.2.1: node-notifier@^5.2.1:
version "5.2.1" version "5.2.1"
resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-5.2.1.tgz#fa313dd08f5517db0e2502e5758d664ac69f9dea" resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-5.2.1.tgz#fa313dd08f5517db0e2502e5758d664ac69f9dea"

Loading…
Cancel
Save