Skip to content

Commit

Permalink
fix: Get firmware version will exit the nervos app, so remove get fir…
Browse files Browse the repository at this point in the history
…mware version (#3179)
  • Loading branch information
yanguoyu authored May 29, 2024
1 parent cfef054 commit 6af3274
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import Button from 'widgets/Button'
import { getDevices, getDeviceFirmwareVersion, getDeviceCkbAppVersion, connectDevice } from 'services/remote'
import { getDevices, getDeviceCkbAppVersion, connectDevice } from 'services/remote'
import { isSuccessResponse, errorFormatter, useDidMount } from 'utils'
import { ReactComponent as SuccessInfo } from 'widgets/Icons/SuccessInfo.svg'
import { Error as ErrorIcon } from 'widgets/Icons/icon'
Expand Down Expand Up @@ -50,7 +50,6 @@ const DetectDevice = ({ dispatch, model }: { dispatch: React.Dispatch<ActionType
const [scanning, setScanning] = useState(true)
const [error, setError] = useState('')
const [appVersion, setAppVersion] = useState('')
const [firmwareVersion, setFirmwareVersion] = useState('')

const findDevice = useCallback(async () => {
setError('')
Expand All @@ -76,10 +75,6 @@ const DetectDevice = ({ dispatch, model }: { dispatch: React.Dispatch<ActionType
setScanning(false)
throw new ConnectFailedException(errorFormatter(connectionRes.message, t))
}
const firmwareVersionRes = await getDeviceFirmwareVersion(device.descriptor)
if (isSuccessResponse(firmwareVersionRes)) {
setFirmwareVersion(firmwareVersionRes.result!)
}
const ckbVersionRes = await getDeviceCkbAppVersion(device.descriptor)
if (isSuccessResponse(ckbVersionRes)) {
setAppVersion(ckbVersionRes.result!)
Expand Down Expand Up @@ -117,9 +112,6 @@ const DetectDevice = ({ dispatch, model }: { dispatch: React.Dispatch<ActionType
<h3 className={styles.model}>{productName}</h3>
{errorMsg ? <Info isError msg={errorMsg} /> : null}
{scanning ? <Info isWaiting={scanning} msg={t('import-hardware.waiting')} /> : null}
{firmwareVersion && !errorMsg && !scanning ? (
<Info msg={t('import-hardware.firmware-version', { version: firmwareVersion })} />
) : null}
{appVersion ? <Info msg={t('import-hardware.app-version', { version: appVersion })} /> : null}
</section>
<footer className={styles.dialogFooter}>
Expand Down
1 change: 0 additions & 1 deletion packages/neuron-ui/src/services/remote/hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export type Version = string

export const getDevices = remoteApi<Model | null, DeviceInfo[]>('detect-device')
export const getDeviceCkbAppVersion = remoteApi<Descriptor, Version>('get-device-ckb-app-version')
export const getDeviceFirmwareVersion = remoteApi<Descriptor, Version>('get-device-firmware-version')
export const getDeviceExtendedPublickey = remoteApi<void, ExtendedPublicKey>('get-device-extended-public-key')
export const getDevicePublicKey = remoteApi<void, PublicKey>('get-device-public-key')
export const connectDevice = remoteApi<DeviceInfo, void>('connect-device')
Expand Down
1 change: 0 additions & 1 deletion packages/neuron-ui/src/services/remote/remoteApiWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ type Action =
// Hardware Wallet
| 'detect-device'
| 'get-device-ckb-app-version'
| 'get-device-firmware-version'
| 'get-device-public-key'
| 'get-device-extended-public-key'
| 'connect-device'
Expand Down
4 changes: 0 additions & 4 deletions packages/neuron-wallet/src/controllers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,6 @@ export default class ApiController {
return this.#hardwareController.getCkbAppVersion()
})

handle('get-device-firmware-version', async () => {
return this.#hardwareController.getFirmwareVersion()
})

handle('get-device-extended-public-key', async () => {
return this.#hardwareController.getExtendedPublicKey()
})
Expand Down
10 changes: 0 additions & 10 deletions packages/neuron-wallet/src/controllers/hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ export default class HardwareController {
}
}

public async getFirmwareVersion(): Promise<Controller.Response<string>> {
const device = HardwareWalletService.getInstance().getCurrent()!
const version = await device.getFirmwareVersion?.()

return {
status: ResponseCode.Success,
result: version,
}
}

public async getExtendedPublicKey(): Promise<Controller.Response<ExtendedPublicKey>> {
const device = HardwareWalletService.getInstance().getCurrent()!
const pubkey = await device.getExtendedPublicKey()
Expand Down
1 change: 0 additions & 1 deletion packages/neuron-wallet/src/services/hardware/hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ export abstract class Hardware {
public abstract signMessage(path: string, messageHex: string): Promise<string>
public abstract disconnect(): Promise<void>
public abstract getAppVersion(): Promise<string>
public abstract getFirmwareVersion?(): Promise<string>
public abstract signTransaction(
walletID: string,
tx: Transaction,
Expand Down
10 changes: 0 additions & 10 deletions packages/neuron-wallet/src/services/hardware/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,6 @@ export default class Ledger extends Hardware {
return conf!.version
}

async getFirmwareVersion(): Promise<string> {
const res: Buffer = await this.transport!.send(0xe0, 0x01, 0x00, 0x00)!
const byteArray = [...res]
const data = byteArray.slice(0, byteArray.length - 2)
const versionLength = data[4]
const version = Buffer.from(data.slice(5, 5 + versionLength)).toString()

return version
}

async getPublicKey(path: string) {
const networkService = NetworksService.getInstance()
const isTestnet = !networkService.isMainnet()
Expand Down

1 comment on commit 6af3274

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 9284026722

Please sign in to comment.