From 8d3a7224ddc41baed1a84fa7fcca42aee02d4468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 3 Jul 2018 13:44:07 +0200 Subject: [PATCH 1/6] Prefix 'Ledger Live' when we display the version --- src/components/RenderError.js | 2 +- src/components/SettingsPage/sections/About.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/RenderError.js b/src/components/RenderError.js index 32dc86b2..a7ea33e0 100644 --- a/src/components/RenderError.js +++ b/src/components/RenderError.js @@ -136,7 +136,7 @@ ${error.stack || 'no stacktrace'}`} fontSize: 10, }} > - {__APP_VERSION__} + {`Ledger Live ${__APP_VERSION__}`} {children} diff --git a/src/components/SettingsPage/sections/About.js b/src/components/SettingsPage/sections/About.js index 460d56eb..17b9ffeb 100644 --- a/src/components/SettingsPage/sections/About.js +++ b/src/components/SettingsPage/sections/About.js @@ -40,7 +40,7 @@ class SectionAbout extends PureComponent { /> - + From 5ee50ddd349389f62462875287ee263acf36ab16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 3 Jul 2018 14:39:45 +0200 Subject: [PATCH 2/6] include userAgent in export logs --- src/components/ExportLogsBtn.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ExportLogsBtn.js b/src/components/ExportLogsBtn.js index 389538ea..e69dcb0d 100644 --- a/src/components/ExportLogsBtn.js +++ b/src/components/ExportLogsBtn.js @@ -21,6 +21,7 @@ class ExportLogsBtn extends Component<{ release: __APP_VERSION__, git_commit: __GIT_REVISION__, environment: __DEV__ ? 'development' : 'production', + userAgent: window.navigator.userAgent, }) const path = remote.dialog.showSaveDialog({ title: 'Export logs', From f5ea1e2edca638c5a24a64946069285285d369fe Mon Sep 17 00:00:00 2001 From: meriadec Date: Tue, 3 Jul 2018 15:09:06 +0200 Subject: [PATCH 3/6] Thats why we had yarn.lock --- package.json | 2 +- yarn.lock | 45 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 51ab9216..95599c61 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "babel-plugin-styled-components": "^1.5.0", "chalk": "^2.4.0", "chance": "^1.0.13", - "concurrently": "^3.5.1", + "concurrently": "3.5.1", "dotenv": "^5.0.1", "electron": "1.8.7", "electron-builder": "20.14.7", diff --git a/yarn.lock b/yarn.lock index f1f62680..bdc99385 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2119,6 +2119,10 @@ ansi-html@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" +ansi-regex@^0.2.0, ansi-regex@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9" + ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -2127,6 +2131,10 @@ ansi-regex@^3.0.0, ansi-regex@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" +ansi-styles@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.1.0.tgz#eaecbf66cd706882760b2f4691582b8f55d7a7de" + ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" @@ -4150,6 +4158,16 @@ chainsaw@~0.1.0: dependencies: traverse ">=0.3.0 <0.4" +chalk@0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.5.1.tgz#663b3a648b68b55d04690d49167aa837858f2174" + dependencies: + ansi-styles "^1.1.0" + escape-string-regexp "^1.0.0" + has-ansi "^0.1.0" + strip-ansi "^0.3.0" + supports-color "^0.2.0" + chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -4602,15 +4620,14 @@ concat-stream@1.6.2, concat-stream@^1.5.0, concat-stream@^1.5.2, concat-stream@^ readable-stream "^2.2.2" typedarray "^0.0.6" -concurrently@^3.5.1: - version "3.6.0" - resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-3.6.0.tgz#c25e34b156a9d5bd4f256a0d85f6192438ae481f" +concurrently@3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-3.5.1.tgz#ee8b60018bbe86b02df13e5249453c6ececd2521" dependencies: - chalk "^2.4.1" + chalk "0.5.1" commander "2.6.0" date-fns "^1.23.0" lodash "^4.5.1" - read-pkg "^3.0.0" rx "2.3.24" spawn-command "^0.0.2-1" supports-color "^3.2.3" @@ -6134,7 +6151,7 @@ escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -7370,6 +7387,12 @@ hard-source-webpack-plugin@^0.6.0: webpack-sources "^1.0.1" write-json-file "^2.3.0" +has-ansi@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e" + dependencies: + ansi-regex "^0.2.0" + has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -13420,6 +13443,12 @@ strip-ansi@3.0.1, strip-ansi@^3.0.0, strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" +strip-ansi@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.3.0.tgz#25f48ea22ca79187f3174a4db8759347bb126220" + dependencies: + ansi-regex "^0.2.1" + strip-ansi@^4.0.0, strip-ansi@~4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -13527,6 +13556,10 @@ sumchecker@^2.0.2: dependencies: debug "^2.2.0" +supports-color@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" + supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" From 3dccfc3998d5b7e4f362e3a450433a0d273681c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 3 Jul 2018 15:23:06 +0200 Subject: [PATCH 4/6] no need of LOG_IN_CONSOLE, just use DEV_TOOLS env --- src/logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logger.js b/src/logger.js index 8b303651..e2f64c76 100644 --- a/src/logger.js +++ b/src/logger.js @@ -34,7 +34,7 @@ const transports = [ }), ] -if (process.env.NODE_ENV !== 'production' || process.env.LOGS_IN_CONSOLE) { +if (process.env.NODE_ENV !== 'production' || process.env.DEV_TOOLS) { let consoleT if (typeof window === 'undefined') { // on Node we want a concise logger From 5cea367399657386a9c8ebd3eba23f2ff208adee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 3 Jul 2018 15:35:55 +0200 Subject: [PATCH 5/6] Refactor deviceAccess without semaphore using a simple queue --- package.json | 1 - src/helpers/deviceAccess.js | 80 +++++++++++-------------------------- yarn.lock | 4 -- 3 files changed, 23 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index 95599c61..a143110f 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,6 @@ "rxjs": "^6.2.1", "rxjs-compat": "^6.2.1", "secp256k1": "3.3.1", - "semaphore": "^1.1.0", "semver": "^5.5.0", "smoothscroll-polyfill": "^0.4.3", "source-map": "0.7.3", diff --git a/src/helpers/deviceAccess.js b/src/helpers/deviceAccess.js index f6fbc478..590fdddc 100644 --- a/src/helpers/deviceAccess.js +++ b/src/helpers/deviceAccess.js @@ -1,5 +1,4 @@ // @flow -import createSemaphore from 'semaphore' import type Transport from '@ledgerhq/hw-transport' import TransportNodeHid from '@ledgerhq/hw-transport-node-hid' import { DEBUG_DEVICE } from 'config/constants' @@ -10,67 +9,34 @@ import { createCustomErrorClass } from './errors' // and guarantee we do one device access at a time. It also will handle the .close() // NOTE optim: in the future we can debounce the close & reuse the same transport instance. -type WithDevice = (devicePath: string) => (job: (Transport<*>) => Promise) => Promise - -const semaphorePerDevice = {} +type WithDevice = (devicePath: string) => (job: (Transport<*>) => Promise<*>) => Promise const DisconnectedDevice = createCustomErrorClass('DisconnectedDevice') -const remapError = (p: Promise): Promise => - p.catch(e => { - if (e && e.message && e.message.indexOf('HID') >= 0) { - throw new DisconnectedDevice(e.message) - } - throw e - }) +const mapError = e => { + if (e && e.message && e.message.indexOf('HID') >= 0) { + throw new DisconnectedDevice(e.message) + } + throw e +} -export const withDevice: WithDevice = devicePath => { - const sem = - semaphorePerDevice[devicePath] || (semaphorePerDevice[devicePath] = createSemaphore(1)) +let queue = Promise.resolve() - return job => - takeSemaphorePromise(sem, devicePath, async () => { - const t = await retry(() => TransportNodeHid.open(devicePath), { maxRetry: 1 }) +export const withDevice: WithDevice = devicePath => job => { + const p = queue.then(async () => { + const t = await retry(() => TransportNodeHid.open(devicePath), { maxRetry: 1 }) + if (DEBUG_DEVICE) { + t.setDebugMode(true) + } + try { + const res = await job(t).catch(mapError) + return res + } finally { + await t.close() + } + }) - if (DEBUG_DEVICE) t.setDebugMode(true) - try { - const res = await remapError(job(t)) - // $FlowFixMe - return res - } finally { - await t.close() - } - }) -} + queue = p.catch(() => null) -function takeSemaphorePromise(sem, devicePath, f: () => Promise): Promise { - return new Promise((resolve, reject) => { - sem.take(() => { - process.send({ - type: 'setDeviceBusy', - busy: true, - devicePath, - }) - f().then( - r => { - sem.leave() - resolve(r) - process.send({ - type: 'setDeviceBusy', - busy: false, - devicePath, - }) - }, - e => { - sem.leave() - reject(e) - process.send({ - type: 'setDeviceBusy', - busy: false, - devicePath, - }) - }, - ) - }) - }) + return p } diff --git a/yarn.lock b/yarn.lock index bdc99385..2be06201 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12810,10 +12810,6 @@ selfsigned@^1.9.1: dependencies: node-forge "0.7.5" -semaphore@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/semaphore/-/semaphore-1.1.0.tgz#aaad8b86b20fe8e9b32b16dc2ee682a8cd26a8aa" - semver-diff@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" From 8a7fcd506c065ea6e5d8966298a3b6853d56c6a7 Mon Sep 17 00:00:00 2001 From: dasilvarosa Date: Tue, 3 Jul 2018 15:49:02 +0200 Subject: [PATCH 6/6] minor correction in trading disclaimer --- static/i18n/en/app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/i18n/en/app.yml b/static/i18n/en/app.yml index 59ffc2c8..6f6fb9f4 100644 --- a/static/i18n/en/app.yml +++ b/static/i18n/en/app.yml @@ -414,5 +414,5 @@ crash: disclaimerModal: title: Trade safely desc_1: Before sending and receiving crypto assets, educate yourself to make informed decisions. Crypto assets are volatile and the prices can go up and down. Carefully evaluate your trading goals and the financial risk you are willing to take. - desc_2: Please beware that Ledger does not provide financial, tax, or legal advice. You should take such decisions on your own or rely on opinions of reliable experts. + desc_2: Please beware that Ledger does not provide financial, tax, or legal advice. You should take such decisions on your own or consult with reliable experts. cta: Got it