Browse Source
Merge pull request #1501 from gre/patch-dgb-update
Update DGB support
master
Gaëtan Renaudeau
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with
29 additions and
13 deletions
-
package.json
-
src/components/EnsureDeviceApp.js
-
src/config/errors.js
-
src/helpers/errors.js
-
src/helpers/getAddressForCurrency/btc.js
-
static/i18n/en/errors.json
-
yarn.lock
|
|
@ -38,8 +38,8 @@ |
|
|
|
"@ledgerhq/hw-app-xrp": "^4.13.0", |
|
|
|
"@ledgerhq/hw-transport": "^4.13.0", |
|
|
|
"@ledgerhq/hw-transport-node-hid": "4.22.0", |
|
|
|
"@ledgerhq/ledger-core": "2.0.0-rc.6", |
|
|
|
"@ledgerhq/live-common": "^3.4.0", |
|
|
|
"@ledgerhq/ledger-core": "2.0.0-rc.7", |
|
|
|
"@ledgerhq/live-common": "^3.5.1", |
|
|
|
"animated": "^0.2.2", |
|
|
|
"async": "^2.6.1", |
|
|
|
"axios": "^0.18.0", |
|
|
|
|
|
@ -20,7 +20,7 @@ import IconUsb from 'icons/Usb' |
|
|
|
|
|
|
|
import type { Device } from 'types/common' |
|
|
|
|
|
|
|
import { WrongDeviceForAccount, CantOpenDevice, BtcUnmatchedApp } from 'config/errors' |
|
|
|
import { WrongDeviceForAccount, CantOpenDevice, UpdateYourApp } from 'config/errors' |
|
|
|
import { getCurrentDevice } from 'reducers/devices' |
|
|
|
|
|
|
|
const usbIcon = <IconUsb size={16} /> |
|
|
@ -61,10 +61,10 @@ class EnsureDeviceApp extends Component<{ |
|
|
|
}, |
|
|
|
{ |
|
|
|
shouldThrow: (err: Error) => { |
|
|
|
const isWrongApp = err instanceof BtcUnmatchedApp |
|
|
|
const isWrongDevice = err instanceof WrongDeviceForAccount |
|
|
|
const isCantOpenDevice = err instanceof CantOpenDevice |
|
|
|
return isWrongApp || isWrongDevice || isCantOpenDevice |
|
|
|
const isUpdateYourApp = err instanceof UpdateYourApp |
|
|
|
return isWrongDevice || isCantOpenDevice || isUpdateYourApp |
|
|
|
}, |
|
|
|
}, |
|
|
|
) |
|
|
|
|
|
@ -33,6 +33,7 @@ export const NotEnoughBalance = createCustomErrorClass('NotEnoughBalance') |
|
|
|
export const PasswordsDontMatchError = createCustomErrorClass('PasswordsDontMatch') |
|
|
|
export const PasswordIncorrectError = createCustomErrorClass('PasswordIncorrect') |
|
|
|
export const TimeoutTagged = createCustomErrorClass('TimeoutTagged') |
|
|
|
export const UpdateYourApp = createCustomErrorClass('UpdateYourApp') |
|
|
|
export const UserRefusedAddress = createCustomErrorClass('UserRefusedAddress') |
|
|
|
export const UserRefusedFirmwareUpdate = createCustomErrorClass('UserRefusedFirmwareUpdate') |
|
|
|
export const UserRefusedOnDevice = createCustomErrorClass('UserRefusedOnDevice') // TODO rename because it's just for transaction refusal
|
|
|
|
|
|
@ -6,10 +6,10 @@ const errorClasses = {} |
|
|
|
|
|
|
|
export const createCustomErrorClass = (name: string): Class<any> => { |
|
|
|
const C = function CustomError(message?: string, fields?: Object) { |
|
|
|
Object.assign(this, fields) |
|
|
|
this.name = name |
|
|
|
this.message = message || name |
|
|
|
this.stack = new Error().stack |
|
|
|
Object.assign(this, fields) |
|
|
|
} |
|
|
|
// $FlowFixMe
|
|
|
|
C.prototype = new Error() |
|
|
|
|
|
@ -3,9 +3,13 @@ |
|
|
|
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' |
|
|
|
import Btc from '@ledgerhq/hw-app-btc' |
|
|
|
import type Transport from '@ledgerhq/hw-transport' |
|
|
|
import { BtcUnmatchedApp } from 'config/errors' |
|
|
|
import { BtcUnmatchedApp, UpdateYourApp } from 'config/errors' |
|
|
|
import getBitcoinLikeInfo from '../devices/getBitcoinLikeInfo' |
|
|
|
|
|
|
|
const oldP2SH = { |
|
|
|
digibyte: 5, |
|
|
|
} |
|
|
|
|
|
|
|
export default async ( |
|
|
|
transport: Transport<*>, |
|
|
|
currency: CryptoCurrency, |
|
|
@ -25,6 +29,13 @@ export default async ( |
|
|
|
if (bitcoinLikeInfo) { |
|
|
|
const { P2SH, P2PKH } = await getBitcoinLikeInfo(transport) |
|
|
|
if (P2SH !== bitcoinLikeInfo.P2SH || P2PKH !== bitcoinLikeInfo.P2PKH) { |
|
|
|
if ( |
|
|
|
currency.id in oldP2SH && |
|
|
|
P2SH === oldP2SH[currency.id] && |
|
|
|
P2PKH === bitcoinLikeInfo.P2PKH |
|
|
|
) { |
|
|
|
throw new UpdateYourApp(`UpdateYourApp ${currency.id}`, currency) |
|
|
|
} |
|
|
|
throw new BtcUnmatchedApp(`BtcUnmatchedApp ${currency.id}`, currency) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -139,6 +139,10 @@ |
|
|
|
"title": "Receive address rejected", |
|
|
|
"description": "Please try again or contact Ledger Support" |
|
|
|
}, |
|
|
|
"UpdateYourApp": { |
|
|
|
"title": "App update required. Uninstall and reinstall the {{managerAppName}} app in the Manager", |
|
|
|
"description": null |
|
|
|
}, |
|
|
|
"WebsocketConnectionError": { |
|
|
|
"title": "Sorry, try again (websocket error).", |
|
|
|
"description": null |
|
|
|
|
|
@ -1536,9 +1536,9 @@ |
|
|
|
dependencies: |
|
|
|
events "^2.0.0" |
|
|
|
|
|
|
|
"@ledgerhq/ledger-core@2.0.0-rc.6": |
|
|
|
version "2.0.0-rc.6" |
|
|
|
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.6.tgz#a08c84bd91c680cd731e1030ce081a9b568a2c47" |
|
|
|
"@ledgerhq/ledger-core@2.0.0-rc.7": |
|
|
|
version "2.0.0-rc.7" |
|
|
|
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.7.tgz#36a2573f01a1e19c51c6e39692e6b0f8be6c3a77" |
|
|
|
dependencies: |
|
|
|
"@ledgerhq/hw-app-btc" "^4.7.3" |
|
|
|
"@ledgerhq/hw-transport-node-hid" "^4.7.6" |
|
|
@ -1549,9 +1549,9 @@ |
|
|
|
npm "^5.7.1" |
|
|
|
prebuild-install "^2.2.2" |
|
|
|
|
|
|
|
"@ledgerhq/live-common@^3.4.0": |
|
|
|
version "3.4.0" |
|
|
|
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.4.0.tgz#49a9f8865d2e3ea898cfba15d69bdaf32c949f80" |
|
|
|
"@ledgerhq/live-common@^3.5.1": |
|
|
|
version "3.5.1" |
|
|
|
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.5.1.tgz#dab3eb061f361999a9e04ef564808831faac61ea" |
|
|
|
dependencies: |
|
|
|
axios "^0.18.0" |
|
|
|
bignumber.js "^7.2.1" |
|
|
|