diff --git a/package.json b/package.json index feadb2f5..56a78dbe 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "@ledgerhq/hw-app-eth": "^4.7.3", "@ledgerhq/hw-transport": "^4.7.3", "@ledgerhq/hw-transport-node-hid": "^4.7.3", + "@ledgerhq/wallet-common": "^0.6.0", "axios": "^0.18.0", "bcryptjs": "^2.4.3", "bitcoinjs-lib": "^3.3.2", diff --git a/src/helpers/btc.js b/src/helpers/btc.js index 83bb323a..2a94ce2c 100644 --- a/src/helpers/btc.js +++ b/src/helpers/btc.js @@ -30,7 +30,7 @@ export function computeOperation(addresses: Array) { .filter(i => addresses.includes(i.address)) .reduce((acc, cur) => acc + cur.value, 0) const amount = outputVal - inputVal - console.warn('assiging a fake account id and blockHeight to operation') + console.warn('assiging a fake account id and blockHeight to operation') // eslint-disable-line no-console return { id: t.hash, hash: t.hash, @@ -92,7 +92,7 @@ export async function getAccount({ network: Object, asyncDelay?: number, onProgress?: Function, -}) { +}): Promise { const script = segwit ? parseInt(network.scriptHash, 10) : parseInt(network.pubKeyHash, 10) let balance = 0 diff --git a/src/reducers/accounts.js b/src/reducers/accounts.js index e49d04ba..b6eec5e2 100644 --- a/src/reducers/accounts.js +++ b/src/reducers/accounts.js @@ -6,7 +6,7 @@ import { createAccountModel } from '@ledgerhq/wallet-common/lib/models/account' import every from 'lodash/every' import get from 'lodash/get' import reduce from 'lodash/reduce' -import type { Account, AccountRaw } from '@ledgerhq/wallet-common/lib/types' +import type { Account } from '@ledgerhq/wallet-common/lib/types' import type { State } from 'reducers' @@ -90,7 +90,10 @@ export function canCreateAccount(state: State): boolean { return every(getAccounts(state), a => get(a, 'operations.length', 0) > 0) } -export function serializeAccounts(accounts: AccountRaw[]): Account[] { +// 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. +export function serializeAccounts(accounts: any): Account[] { // ensure that accounts are always wrapped in data key if (accounts.length && !accounts[0].data) { accounts = accounts.map(account => ({ data: account })) @@ -98,7 +101,7 @@ export function serializeAccounts(accounts: AccountRaw[]): Account[] { return accounts.map(accountModel.decode) } -export function deserializeAccounts(accounts: Account[]): AccountRaw[] { +export function deserializeAccounts(accounts: Account[]) { return accounts.map(accountModel.encode) } diff --git a/yarn.lock b/yarn.lock index bf374774..ff0ed7cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -913,7 +913,7 @@ lodash "^4.2.0" to-fast-properties "^2.0.0" -"@ledgerhq/currencies@^4.7.3": +"@ledgerhq/currencies@^4.7.1", "@ledgerhq/currencies@^4.7.3": version "4.7.3" resolved "https://registry.yarnpkg.com/@ledgerhq/currencies/-/currencies-4.7.3.tgz#0e28c0f1c74cf00b990be6865fbec374f808b71f" dependencies: @@ -947,6 +947,19 @@ dependencies: events "^2.0.0" +"@ledgerhq/wallet-common@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/wallet-common/-/wallet-common-0.6.0.tgz#e6a77fada1e3eaef4d6e59f3ea5cebaf0a276a63" + dependencies: + "@ledgerhq/currencies" "^4.7.1" + axios "^0.18.0" + babel-jest "^23.0.0-alpha.0" + invariant "^2.2.2" + lodash "^4.17.4" + prando "^3.0.1" + react "^16.0.0" + timemachine "^0.3.0" + "@posthtml/esm@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@posthtml/esm/-/esm-1.0.0.tgz#09bcb28a02438dcee22ad1970ca1d85a000ae0cf" @@ -1889,6 +1902,13 @@ babel-jest@^22.4.3: babel-plugin-istanbul "^4.1.5" babel-preset-jest "^22.4.3" +babel-jest@^23.0.0-alpha.0: + version "23.0.0-alpha.4" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-23.0.0-alpha.4.tgz#e3bb1e486f4178b381cc7b37e6cafb1af3a9d1bf" + dependencies: + babel-plugin-istanbul "^4.1.6" + babel-preset-jest "^23.0.0-alpha.4" + babel-loader@^7.1.2: version "7.1.3" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.3.tgz#ff5b440da716e9153abb946251a9ab7670037b16" @@ -1939,10 +1959,23 @@ babel-plugin-istanbul@^4.1.5: istanbul-lib-instrument "^1.7.5" test-exclude "^4.1.1" +babel-plugin-istanbul@^4.1.6: + version "4.1.6" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz#36c59b2192efce81c5b378321b74175add1c9a45" + dependencies: + babel-plugin-syntax-object-rest-spread "^6.13.0" + find-up "^2.1.0" + istanbul-lib-instrument "^1.10.1" + test-exclude "^4.2.1" + babel-plugin-jest-hoist@^22.4.3: version "22.4.3" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.4.3.tgz#7d8bcccadc2667f96a0dcc6afe1891875ee6c14a" +babel-plugin-jest-hoist@^23.0.0-alpha.4: + version "23.0.0-alpha.4" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.0.0-alpha.4.tgz#3f32715d54640e37cc62a84a9d3d7eada6a067fc" + babel-plugin-minify-builtins@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/babel-plugin-minify-builtins/-/babel-plugin-minify-builtins-0.2.0.tgz#317f824b0907210b6348671bb040ca072e2e0c82" @@ -2542,6 +2575,13 @@ babel-preset-jest@^22.4.3: babel-plugin-jest-hoist "^22.4.3" babel-plugin-syntax-object-rest-spread "^6.13.0" +babel-preset-jest@^23.0.0-alpha.4: + version "23.0.0-alpha.4" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-23.0.0-alpha.4.tgz#d3080507330e6d23c47dcc366d69f7a330174f70" + dependencies: + babel-plugin-jest-hoist "^23.0.0-alpha.4" + babel-plugin-syntax-object-rest-spread "^6.13.0" + babel-preset-minify@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/babel-preset-minify/-/babel-preset-minify-0.2.0.tgz#006566552d9b83834472273f306c0131062a0acc" @@ -4817,7 +4857,7 @@ electron-builder-lib@~20.6.2: semver "^5.5.0" temp-file "^3.1.1" -electron-builder@^20.0.4, electron-builder@^20.8.0: +electron-builder@^20.8.0: version "20.8.0" resolved "https://registry.yarnpkg.com/electron-builder/-/electron-builder-20.8.0.tgz#9f7067dc8a3aa9451d08e0231066556d39d0ffef" dependencies: @@ -4997,7 +5037,7 @@ electron-webpack@^2.0.1: webpack-merge "^4.1.2" yargs "^11.1.0" -electron@1.8.4, electron@^1.8.2: +electron@1.8.4: version "1.8.4" resolved "https://registry.yarnpkg.com/electron/-/electron-1.8.4.tgz#cca8d0e6889f238f55b414ad224f03e03b226a38" dependencies: @@ -7244,12 +7284,28 @@ istanbul-lib-coverage@^1.1.1, istanbul-lib-coverage@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.2.tgz#4113c8ff6b7a40a1ef7350b01016331f63afde14" +istanbul-lib-coverage@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.0.tgz#f7d8f2e42b97e37fe796114cb0f9d68b5e3a4341" + istanbul-lib-hook@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.1.0.tgz#8538d970372cb3716d53e55523dd54b557a8d89b" dependencies: append-transform "^0.4.0" +istanbul-lib-instrument@^1.10.1: + version "1.10.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.10.1.tgz#724b4b6caceba8692d3f1f9d0727e279c401af7b" + dependencies: + babel-generator "^6.18.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + babylon "^6.18.0" + istanbul-lib-coverage "^1.2.0" + semver "^5.3.0" + istanbul-lib-instrument@^1.7.5, istanbul-lib-instrument@^1.8.0, istanbul-lib-instrument@^1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.2.tgz#84905bf47f7e0b401d6b840da7bad67086b4aab6" @@ -9718,6 +9774,10 @@ posthtml@^0.11.2, posthtml@^0.11.3: posthtml-parser "^0.3.3" posthtml-render "^1.1.0" +prando@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/prando/-/prando-3.0.1.tgz#8fa6d856277fad738e50f3e550b702380ad52d6e" + prebuild-install@^2.2.2: version "2.5.1" resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.1.tgz#0f234140a73760813657c413cdccdda58296b1da" @@ -10271,7 +10331,7 @@ react-treebeard@^2.1.0: shallowequal "^0.2.2" velocity-react "^1.3.1" -react@^16.2.0: +react@^16.0.0, react@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba" dependencies: @@ -11817,6 +11877,16 @@ test-exclude@^4.1.1: read-pkg-up "^1.0.1" require-main-filename "^1.0.1" +test-exclude@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.2.1.tgz#dfa222f03480bca69207ca728b37d74b45f724fa" + dependencies: + arrify "^1.0.1" + micromatch "^3.1.8" + object-assign "^4.1.0" + read-pkg-up "^1.0.1" + require-main-filename "^1.0.1" + text-table@^0.2.0, text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -11863,6 +11933,10 @@ timed-out@4.0.1, timed-out@^4.0.0, timed-out@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" +timemachine@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/timemachine/-/timemachine-0.3.0.tgz#83e2eb696cbfe4696c1708e6a3700df4e62fc525" + timers-browserify@^2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.6.tgz#241e76927d9ca05f4d959819022f5b3664b64bae"