Skip to content

Commit

Permalink
update ledger functions to use ledgerjs-hw-app-cardano 3.x api (#1379)
Browse files Browse the repository at this point in the history
* update ledger functions to use ledgerjs-hw-app-cardano 3.0.0 api

* flow fixes

* lint + remaining flow errors

* fixes
  • Loading branch information
v-almonacid committed Jun 16, 2021
1 parent 43f9315 commit f40cf47
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 226 deletions.
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ node_modules/warning/.*
.*/node_modules/@react-native-community/cli/.*/.*

; Ignore @ledgerhq/react-native-hw-transport-ble
.*/node_modules/@ledgerhq/react-native-hw-transport-ble/src/BleTransport.js
.*/node_modules/@ledgerhq/react-native-hw-transport-ble/lib/BleTransport.js.flow

; Ignore @emurgo/cardano-serialization-lib-nodejs
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"@babel/core": "7.12.10",
"@babel/node": "7.12.6",
"@babel/runtime": "7.12.5",
"@cardano-foundation/ledgerjs-hw-app-cardano": "2.2.1",
"@cardano-foundation/ledgerjs-hw-app-cardano": "3.2.0",
"@emurgo/cip14-js": "2.0.0",
"@emurgo/cip4-js": "1.0.5",
"@emurgo/react-native-haskell-shelley": "1.1.4",
"@ledgerhq/react-native-hw-transport-ble": "5.41.0",
"@ledgerhq/react-native-hw-transport-ble": "5.51.1",
"@react-native-async-storage/async-storage": "1.15.5",
"@react-native-community/clipboard": "1.5.1",
"@react-native-community/masked-view": "0.1.10",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Ledger/DeviceItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {compose, withHandlers, withStateHandlers} from 'recompose'
import {COLORS} from '../../styles/config'

import type {ComponentType} from 'react'
import type {Device} from '@ledgerhq/react-native-hw-transport-ble'
import type {Device} from './types'

const styles = StyleSheet.create({
deviceItem: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Ledger/LedgerConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import styles from './styles/LedgerConnect.style'
import bleImage from '../../assets/img/bluetooth.png'
import usbImage from '../../assets/img/ledger-nano-usb.png'

import type {Device} from '@ledgerhq/react-native-hw-transport-ble'
import type {Device} from './types'
import type {DeviceId, DeviceObj} from '../../crypto/shelley/ledgerUtils'

const messages = defineMessages({
Expand Down
6 changes: 6 additions & 0 deletions src/components/Ledger/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @flow

//
export type Device = {
id: number,
}
2 changes: 2 additions & 0 deletions src/components/Receive/AddressView.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {errorMessages} from '../../i18n/global-messages'
import LocalizableError from '../../i18n/LocalizableError'
import {Logger} from '../../utils/logging'
import {CONFIG} from '../../config/config'
import {getCardanoByronConfig} from '../../config/networks'

import styles from './styles/AddressView.style'
import infoIcon from '../../assets/img/icon/info.png'
Expand Down Expand Up @@ -59,6 +60,7 @@ const _handleOnVerifyAddress = async (
await verifyAddress(
walletMeta.walletImplementationId,
walletMeta.networkId,
getCardanoByronConfig().PROTOCOL_MAGIC,
address,
addressingInfo,
hwDeviceInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import LocalizableError from '../../../i18n/LocalizableError'
import styles from './styles/ConnectNanoXScreen.style'

import type {ComponentType} from 'react'
import type {Device} from '@ledgerhq/react-native-hw-transport-ble'
import type {Device} from '../../Ledger/types'
import type {Navigation} from '../../../types/navigation'
import type {DeviceId, DeviceObj} from '../../../crypto/shelley/ledgerUtils'

Expand Down
2 changes: 1 addition & 1 deletion src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const HARDWARE_WALLETS = {
MODEL: 'Nano',
ENABLE_USB_TRANSPORT: true,
USB_MIN_SDK: 24, // USB transport officially supported for Android SDK >= 24
MIN_ADA_APP_VERSION: '2.1.0',
MIN_ADA_APP_VERSION: '2.2.1',
},
}

Expand Down
3 changes: 2 additions & 1 deletion src/crypto/shelley/ShelleyWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ export default class ShelleyWallet extends Wallet implements WalletInterface {
const ledgerSignTxPayload = await createLedgerSignTxPayload({
signRequest: request,
byronNetworkMagic: getCardanoByronConfig().PROTOCOL_MAGIC,
networkId: Number.parseInt(this._getChainNetworkId(), 10),
// to not confuse with wallet's network id
chainNetworkId: Number.parseInt(this._getChainNetworkId(), 10),
addressingMap,
})

Expand Down

0 comments on commit f40cf47

Please sign in to comment.