Browse Source

Merge branch 'master' into bump-deps

master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
8a923e5bed
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/helpers/countervalues.js
  2. 23
      src/helpers/db.js
  3. 39
      src/reducers/accounts.js
  4. 8
      src/reducers/settings.js
  5. 1
      static/i18n/fr/accountsOrder.yml
  6. 26
      static/i18n/fr/onboarding.yml

2
src/helpers/countervalues.js

@ -20,7 +20,7 @@ const pairsSelector = createSelector(
[
{ from: intermediaryCurrency, to: counterValueCurrency, exchange: counterValueExchange },
].concat(
currencies.filter(c => c !== intermediaryCurrency).map(currency => ({
currencies.filter(c => c.ticker !== intermediaryCurrency.ticker).map(currency => ({
from: currency,
to: intermediaryCurrency,
exchange: currencySettingsSelector(state, { currency }).exchange,

23
src/helpers/db.js

@ -4,7 +4,7 @@ import Store from 'electron-store'
import set from 'lodash/set'
import get from 'lodash/get'
import { serializeAccounts, deserializeAccounts } from 'reducers/accounts'
import { decodeAccountsModel, encodeAccountsModel } from 'reducers/accounts'
type DBKey = 'settings' | 'accounts' | 'countervalues'
@ -23,17 +23,20 @@ export function setEncryptionKey(key: DBKey, value?: string) {
encryptionKey[key] = value
}
function middleware(type, key, data: any) {
if (key === 'accounts') {
if (type === 'get') {
data = serializeAccounts(data)
}
const transforms = {
get: {
accounts: decodeAccountsModel,
},
set: {
accounts: encodeAccountsModel,
},
}
if (type === 'set') {
data = deserializeAccounts(data)
}
function middleware(type: 'get' | 'set', key: string, data: any) {
const t = transforms[type][key]
if (t) {
data = t(data)
}
return data
}

39
src/reducers/accounts.js

@ -59,9 +59,7 @@ const handlers: Object = {
// Selectors
export function accountsSelector(state: { accounts: AccountsState }): Account[] {
return state.accounts
}
export const accountsSelector = (state: { accounts: AccountsState }): Account[] => state.accounts
export const currenciesSelector = createSelector(accountsSelector, accounts =>
[...new Set(accounts.map(a => a.currency))].sort((a, b) => a.name.localeCompare(b.name)),
@ -73,41 +71,16 @@ export const accountSelector = createSelector(
(accounts, accountId) => accounts.find(a => a.id === accountId),
)
export function decodeAccount(account: AccountRaw): Account {
return accountModel.decode({
export const decodeAccount = (account: AccountRaw): Account =>
accountModel.decode({
data: account,
version: accountModel.version,
})
}
export function encodeAccount(account: Account): AccountRaw {
return accountModel.encode(account).data
}
// Yeah. `any` should be `AccountRaw[]` but it can also be a map
// of wrapped accounts. And as flow is apparently incapable of doing
// such a simple thing, let's put any, right? I don't care.
// FIXME: no it shouldn't. the purpose of DataModel is to contain the version, it's the only way we can run the migration functions
export function serializeAccounts(accounts: any): Account[] {
// ensure that accounts are always wrapped in data key
if (accounts && accounts.length && !accounts[0].data) {
accounts = accounts.map(account => ({ data: account }))
}
return accounts ? accounts.map(accountModel.decode) : []
}
export const encodeAccount = (account: Account): AccountRaw => accountModel.encode(account).data
export function deserializeAccounts(accounts: Account[]): Array<any> {
return accounts.map(account => {
// as account can be passed by main process, the Date types
// can be converted to string. we ensure here that we have real
// date
// FIXME Account shouldn't be passed by main process. only AccountRaw should be!
if (typeof account.lastSyncDate === 'string') {
account.lastSyncDate = new Date(account.lastSyncDate)
}
export const decodeAccountsModel = (raws: *) => (raws || []).map(accountModel.decode)
return accountModel.encode(account)
})
}
export const encodeAccountsModel = (accounts: *) => (accounts || []).map(accountModel.encode)
export default handleActions(handlers, state)

8
src/reducers/settings.js

@ -76,7 +76,6 @@ const INITIAL_STATE: SettingsState = {
}
function asCryptoCurrency(c: Currency): ?CryptoCurrency {
// $FlowFixMe
return 'id' in c ? c : null
}
@ -98,12 +97,15 @@ const handlers: Object = {
copy.currenciesSettings = { ...copy.currenciesSettings }
for (const { to, from, exchange } of pairs) {
const fromCrypto = asCryptoCurrency(from)
if (fromCrypto && to === intermediaryCurrency) {
if (fromCrypto && to.ticker === intermediaryCurrency.ticker) {
copy.currenciesSettings[fromCrypto.id] = {
...copy.currenciesSettings[fromCrypto.id],
exchange,
}
} else if (from === intermediaryCurrency && to === counterValueCurrency) {
} else if (
from.ticker === intermediaryCurrency.ticker &&
to.ticker === counterValueCurrency.ticker
) {
copy.counterValueExchange = exchange
}
}

1
static/i18n/fr/accountsOrder.yml

@ -1,4 +1,3 @@
---
name: Alphabétique
balance: Balance
type: Crypto-monnaie

26
static/i18n/fr/onboarding.yml

@ -1,7 +1,6 @@
---
start:
title: Welcome to the new Ledger Live Desktop app.
desc: Let’s get started!
title: Welcome to Ledger Live
init:
title: Welcome to Ledger Live, the computer companion app to your Ledger device
newDevice:
@ -18,7 +17,6 @@ init:
desc: Please replace it with the final wording once it’s done.
selectDevice:
title: To get started, select your device
desc: This is a long text, please replace it with the final wording once it’s done. Lorem ipsum dolor amet ledger lorem dolor ipsum amet
ledgerNanoCard:
title: Ledger Nano S
desc: Please replace it with the final wording once it’s done.
@ -42,12 +40,25 @@ selectPIN:
note2: An 8-digit PIN code offers an optimum level of security.
note3: Never use a device supplied with a PIN code and/or a 24-word recovery phrase.
writeSeed:
title: Save your recovery phrase
desc: Your recovery phrase is formed by 24 words. They will be displayed only once.
instructions:
restore:
title: Save your recovery phrase
desc: Your recovery phrase is formed by 24 words. They will be displayed only once.
step1: Press the right button to select the length of your recovery phrase. Press both buttons to confirm.
step2: Select the first letters of Word \
step3: Select Word \
step4: Repeat the process until the last word.
nano:
title: Save your recovery phrase
desc: Your recovery phrase is formed by 24 words. They will be displayed only once.
step1: Copy the first word (Word \
step2: Press the right button to display Word \
step3: Confirm your recovery phrase press both buttons to validate each word displayed on the screen.
blue:
title: Save your recovery phrase
desc: Your recovery phrase is formed by 24 words. They will be displayed only once.
step1: Copy each word of the recovery phrase on the blank Recovery sheet. Make sure to copy the words in the same order.
step2: Tap NEXT to display the following words. Tap PREVIOUS to go back.
step3: Enter the requested words to confirm your recovery phrase.
disclaimer:
note1: Carefully secure your 24 words out of sight.
note2: Ledger does not keep any backup of your 24 words.
@ -89,6 +100,9 @@ analytics:
termsConditions:
title: Terms and Conditions
desc: Please accept terms and conditions to proceed
sentryLogs:
title: Sentry Logs
desc: Help Ledger improve its products and services by automatically sending diagnostics and usage data.
finish:
title: This is the title of the screen. 1 line is the maximum
desc: This is a long text, please replace it with the final wording once it’s done.
Lorem ipsum dolor amet ledger lorem dolor ipsum amet

Loading…
Cancel
Save