Browse Source

Update DGB support

master
Gaëtan Renaudeau 7 years ago
parent
commit
5deaa30413
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 2
      package.json
  2. 6
      src/components/EnsureDeviceApp.js
  3. 1
      src/config/errors.js
  4. 2
      src/helpers/errors.js
  5. 13
      src/helpers/getAddressForCurrency/btc.js
  6. 4
      static/i18n/en/errors.json
  7. 6
      yarn.lock

2
package.json

@ -39,7 +39,7 @@
"@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/live-common": "^3.5.0",
"animated": "^0.2.2",
"async": "^2.6.1",
"axios": "^0.18.0",

6
src/components/EnsureDeviceApp.js

@ -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
},
},
)

1
src/config/errors.js

@ -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

2
src/helpers/errors.js

@ -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()

13
src/helpers/getAddressForCurrency/btc.js

@ -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)
}
}

4
static/i18n/en/errors.json

@ -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

6
yarn.lock

@ -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.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.5.0.tgz#3176f5f3cdbe600775edd2b5dac5c10addd90e6f"
dependencies:
axios "^0.18.0"
bignumber.js "^7.2.1"

Loading…
Cancel
Save