+ ## Architecture diff --git a/package.json b/package.json index 0708592e..74769625 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "lint": "eslint src webpack .storybook", "ci": "yarn lint && yarn flow && yarn prettier", "postinstall": "bash ./scripts/postinstall.sh", - "prettier": "prettier --write \"{src,webpack,.storybook}/**/*.js\"", + "prettier": "prettier --write \"{src,webpack,.storybook,static/i18n}/**/*.{js,json}\"", "publish-storybook": "bash ./scripts/publish-storybook.sh", "release": "bash ./scripts/release.sh", "start": "bash ./scripts/start.sh", @@ -41,7 +41,7 @@ "@ledgerhq/hw-transport": "^4.13.0", "@ledgerhq/hw-transport-node-hid": "^4.13.0", "@ledgerhq/ledger-core": "2.0.0-rc.4", - "@ledgerhq/live-common": "^2.32.0", + "@ledgerhq/live-common": "^2.35.0", "animated": "^0.2.2", "async": "^2.6.1", "axios": "^0.18.0", diff --git a/scripts/detect-unused-wordings.js b/scripts/detect-unused-wordings.js new file mode 100644 index 00000000..0e8e4d0b --- /dev/null +++ b/scripts/detect-unused-wordings.js @@ -0,0 +1,104 @@ +/* eslint-disable no-console */ + +const { spawn } = require('child_process') + +// those wordings are dynamically created, so they are detected +// as false positive +const WHITELIST = [ + 'app:operation.type.IN', + 'app:operation.type.OUT', + 'app:exchange.coinhouse', + 'app:exchange.changelly', + 'app:exchange.coinmama', + 'app:exchange.simplex', + 'app:exchange.paybis', + 'app:addAccounts.accountToImportSubtitle_plural', + 'app:dashboard.summary_plural', + 'app:addAccounts.success_plural', + 'app:addAccounts.successDescription_plural', + 'app:time.since.day', + 'app:time.since.week', + 'app:time.since.month', + 'app:time.since.year', + 'app:time.day', + 'app:time.week', + 'app:time.month', + 'app:time.year', + 'app:addAccounts.cta.add_plural', + 'app:manager.apps.installing', + 'app:manager.apps.uninstalling', + 'app:manager.apps.installSuccess', + 'app:manager.apps.uninstallSuccess', +] + +const WORDINGS = { + app: require('../static/i18n/en/app.json'), + onboarding: require('../static/i18n/en/onboarding.json'), + // errors: require('../static/i18n/en/errors.json'), + // language: require('../static/i18n/en/language.json'), +} + +async function main() { + for (const ns in WORDINGS) { + if (WORDINGS.hasOwnProperty(ns)) { + try { + await cleanNamespace(ns) + } catch (err) { + console.log(err) + } + } + } +} + +async function cleanNamespace(ns) { + const root = WORDINGS[ns] + await checkForUsage(root, ns, ':') +} + +async function checkForUsage(v, key, delimiter = '.') { + if (WHITELIST.includes(key)) { + return + } + if (typeof v === 'object') { + for (const k in v) { + if (v.hasOwnProperty(k)) { + await checkForUsage(v[k], `${key}${delimiter}${k}`) + } + } + } else if (typeof v === 'string') { + try { + const hasOccurences = await getHasOccurrences(key) + if (!hasOccurences) { + console.log(key) + } + } catch (err) { + console.log(err) + } + } else { + throw new Error('invalid input') + } +} + +function getHasOccurrences(key) { + return new Promise(resolve => { + const childProcess = spawn('rg', [key, 'src']) + let data + childProcess.stdout.on('data', d => { + data = d.toString() + }) + childProcess.on('close', () => { + if (!data) return resolve(false) + const rows = data.split('\n').filter(Boolean) + return resolve(rows.length > 0) + }) + childProcess.on('error', err => { + if (err.code === 'ENOENT') { + console.log(`You need to install ripgrep first`) + console.log(`see: https://github.com/BurntSushi/ripgrep`) + process.exit(1) + } + }) + }) +} + +main() diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index c33cf292..eeed781a 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -11,7 +11,7 @@ function MAIN { } function INSTALL_FLOW_TYPED { - LATEST_FLOW_TYPED_COMMIT_HASH=$(curl --silent --header "Accept: application/vnd.github.VERSION.sha" https://api.github.com/repos/flowtype/flow-typed/commits/master) + LATEST_FLOW_TYPED_COMMIT_HASH=$(curl --silent --header "Accept: application/vnd.github.VERSION.sha" --location https://api.github.com/repos/flowtype/flow-typed/commits/master) CURRENT_FLOW_TYPED_HASH=$(GET_HASH 'flow-typed') if [ "$LATEST_FLOW_TYPED_COMMIT_HASH" == "$CURRENT_FLOW_TYPED_HASH" ]; then echo "> Flow-typed definitions are up to date. Skipping" diff --git a/src/commands/libcoreSignAndBroadcast.js b/src/commands/libcoreSignAndBroadcast.js index 14a8f063..07f36f7a 100644 --- a/src/commands/libcoreSignAndBroadcast.js +++ b/src/commands/libcoreSignAndBroadcast.js @@ -121,9 +121,14 @@ async function signTransaction({ const changePath = output ? output.getDerivationPath().toString() : undefined const outputScriptHex = Buffer.from(transaction.serializeOutputs()).toString('hex') - const lockTime = undefined // TODO: transaction.getLockTime() const initialTimestamp = hasTimestamp ? transaction.getTimestamp() : undefined + // FIXME + // should be `transaction.getLockTime()` as soon as lock time is + // handled by libcore (actually: it always returns a default value + // and that caused issue with zcash (see #904)) + const lockTime = undefined + const signedTransaction = await hwApp.createPaymentTransactionNew( inputs, associatedKeysets, diff --git a/src/components/ManagerPage/Dashboard.js b/src/components/ManagerPage/Dashboard.js index ee17b825..9c304bed 100644 --- a/src/components/ManagerPage/Dashboard.js +++ b/src/components/ManagerPage/Dashboard.js @@ -33,12 +33,10 @@ const Dashboard = ({ device, deviceInfo, t, handleHelpRequest }: Props) => (