From d54a3fb832813bb6dd517835e4b8e8ad2ff5b346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 19 Jun 2018 14:59:03 +0200 Subject: [PATCH 1/4] fix ripple scan to show twice a New Account proposal --- src/bridge/RippleJSBridge.js | 37 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/bridge/RippleJSBridge.js b/src/bridge/RippleJSBridge.js index a8fb4621..e1016654 100644 --- a/src/bridge/RippleJSBridge.js +++ b/src/bridge/RippleJSBridge.js @@ -256,6 +256,7 @@ const RippleJSBridge: WalletBridge = { const derivations = getDerivations(currency) for (const derivation of derivations) { + const legacy = derivation !== derivations[derivations.length - 1] for (let index = 0; index < 255; index++) { const freshAddressPath = derivation({ currency, x: index, segwit: false }) const { address } = await await getAddress @@ -280,22 +281,24 @@ const RippleJSBridge: WalletBridge = { if (!info) { // account does not exist in Ripple server // we are generating a new account locally - next({ - id: accountId, - xpub: '', - name: getNewAccountPlaceholderName(currency, index), - freshAddress, - freshAddressPath, - balance: 0, - blockHeight: maxLedgerVersion, - index, - currency, - operations: [], - pendingOperations: [], - unit: currency.units[0], - archived: false, - lastSyncDate: new Date(), - }) + if (!legacy) { + next({ + id: accountId, + xpub: '', + name: getNewAccountPlaceholderName(currency, index), + freshAddress, + freshAddressPath, + balance: 0, + blockHeight: maxLedgerVersion, + index, + currency, + operations: [], + pendingOperations: [], + unit: currency.units[0], + archived: false, + lastSyncDate: new Date(), + }) + } break } @@ -315,7 +318,7 @@ const RippleJSBridge: WalletBridge = { const account: $Exact = { id: accountId, xpub: '', - name: getAccountPlaceholderName(currency, index), + name: getAccountPlaceholderName(currency, index, legacy), freshAddress, freshAddressPath, balance, From 94dea24d2dc1ccff53acde16bcd582bcda7adba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 19 Jun 2018 15:11:52 +0200 Subject: [PATCH 2/4] Fix a rendering bug when you send coin from an account to another --- src/components/OperationsList/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/OperationsList/index.js b/src/components/OperationsList/index.js index 92aacc4d..6fdcece6 100644 --- a/src/components/OperationsList/index.js +++ b/src/components/OperationsList/index.js @@ -119,7 +119,7 @@ export class OperationsList extends PureComponent { Date: Tue, 19 Jun 2018 15:20:37 +0200 Subject: [PATCH 3/4] Bugfix TranslatedError to crash the app in some error cases --- src/components/TranslatedError.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/TranslatedError.js b/src/components/TranslatedError.js index 7cb125ca..0fea7a3d 100644 --- a/src/components/TranslatedError.js +++ b/src/components/TranslatedError.js @@ -4,6 +4,7 @@ // - an error can have parameters, to use them, just use field of the Error object, that's what we give to `t()` // - returned value is intentially not styled (is universal). wrap this in whatever you need +import logger from 'logger' import { PureComponent } from 'react' import { translate } from 'react-i18next' import type { T } from 'types/common' @@ -18,7 +19,12 @@ class TranslatedError extends PureComponent { const { t, error } = this.props if (!error) return null if (typeof error === 'string') return error - return t(`errors:${error.name}`, error) + const translation = t(`errors:${error.name}`, error) + if (translation) { + return translation + } + logger.warn('TranslatedError: no transation!', error.name, error) + return error.message || error.name || '' } } From 34b30c56817824d6d079107876a70999ca181ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 19 Jun 2018 16:28:02 +0200 Subject: [PATCH 4/4] Fix errors --- src/components/TranslatedError.js | 2 +- static/i18n/en/errors.yml | 9 +++++---- static/i18n/fr/errors.yml | 13 +++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/components/TranslatedError.js b/src/components/TranslatedError.js index 0fea7a3d..d9d3f8b5 100644 --- a/src/components/TranslatedError.js +++ b/src/components/TranslatedError.js @@ -24,7 +24,7 @@ class TranslatedError extends PureComponent { return translation } logger.warn('TranslatedError: no transation!', error.name, error) - return error.message || error.name || '' + return error.message || error.name || t('errors:generic') } } diff --git a/static/i18n/en/errors.yml b/static/i18n/en/errors.yml index 456fc91a..8f853eb0 100644 --- a/static/i18n/en/errors.yml +++ b/static/i18n/en/errors.yml @@ -1,7 +1,8 @@ -RangeError: {{message}} -Error: {{message}} -LedgerAPIErrorWithMessage: {{message}} -TransportStatusError: {{message}} +generic: An error occurred +RangeError: '{{message}}' +Error: '{{message}}' +LedgerAPIErrorWithMessage: '{{message}}' +TransportStatusError: '{{message}}' FeeEstimationFailed: 'fee estimation failed (status: {{status}})' NotEnoughBalance: 'Not enough balance' BtcUnmatchedApp: 'You must open application ‘{{currencyName}}’ on the device' diff --git a/static/i18n/fr/errors.yml b/static/i18n/fr/errors.yml index 3a00f039..cc7c183b 100644 --- a/static/i18n/fr/errors.yml +++ b/static/i18n/fr/errors.yml @@ -1,12 +1,9 @@ --- -RangeError: - - message -Error: - - message -LedgerAPIErrorWithMessage: - - message -TransportStatusError: - - message +generic: An error occurred +RangeError: '{{message}}' +Error: '{{message}}' +LedgerAPIErrorWithMessage: '{{message}}' +TransportStatusError: '{{message}}' FeeEstimationFailed: 'fee estimation failed (status: {{status}})' NotEnoughBalance: 'Not enough balance' BtcUnmatchedApp: 'You must open application ‘{{currencyName}}’ on the device'