@onekeyfe/hd-core
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
@@ -7,4 +7,15 @@ import { GetAddress } from '@onekeyfe/hd-transport'; | ||
init(): void; | ||
getVersionRange(): { | ||
model_mini: { | ||
min: string; | ||
}; | ||
model_touch: { | ||
min: string; | ||
}; | ||
} | { | ||
model_mini?: undefined; | ||
model_touch?: undefined; | ||
}; | ||
run(): Promise<BTCAddress | BTCAddress[]>; | ||
} | ||
//# sourceMappingURL=BTCGetAddress.d.ts.map |
@@ -8,4 +8,15 @@ import { GetPublicKey } from '@onekeyfe/hd-transport'; | ||
private isBtcNetwork; | ||
getVersionRange(): { | ||
model_mini: { | ||
min: string; | ||
}; | ||
model_touch: { | ||
min: string; | ||
}; | ||
} | { | ||
model_mini?: undefined; | ||
model_touch?: undefined; | ||
}; | ||
run(): Promise<BTCPublicKey | BTCPublicKey[]>; | ||
} | ||
//# sourceMappingURL=BTCGetPublicKey.d.ts.map |
@@ -5,4 +5,15 @@ import { SignMessage } from '@onekeyfe/hd-transport'; | ||
init(): void; | ||
getVersionRange(): { | ||
model_mini: { | ||
min: string; | ||
}; | ||
model_touch: { | ||
min: string; | ||
}; | ||
} | { | ||
model_mini?: undefined; | ||
model_touch?: undefined; | ||
}; | ||
run(): Promise<import("@onekeyfe/hd-transport").MessageSignature>; | ||
} | ||
//# sourceMappingURL=BTCSignMessage.d.ts.map |
@@ -14,2 +14,13 @@ import { TxInputType, TxOutputType } from '@onekeyfe/hd-transport'; | ||
init(): void; | ||
getVersionRange(): { | ||
model_mini: { | ||
min: string; | ||
}; | ||
model_touch: { | ||
min: string; | ||
}; | ||
} | { | ||
model_mini?: undefined; | ||
model_touch?: undefined; | ||
}; | ||
run(): Promise<import("../../types/api/btcSignTransaction").SignedTransaction>; | ||
@@ -16,0 +27,0 @@ } |
@@ -5,4 +5,15 @@ import { VerifyMessage } from '@onekeyfe/hd-transport'; | ||
init(): void; | ||
getVersionRange(): { | ||
model_mini: { | ||
min: string; | ||
}; | ||
model_touch: { | ||
min: string; | ||
}; | ||
} | { | ||
model_mini?: undefined; | ||
model_touch?: undefined; | ||
}; | ||
run(): Promise<import("@onekeyfe/hd-transport").Success>; | ||
} | ||
//# sourceMappingURL=BTCVerifyMessage.d.ts.map |
import { Deferred } from '@onekeyfe/hd-shared'; | ||
import { BaseMethod } from '../BaseMethod'; | ||
import type { Device } from '../../device/Device'; | ||
import type { Features } from '../../types'; | ||
import type { Device } from '../../device/Device'; | ||
export default class DeviceUpdateBootloader extends BaseMethod { | ||
@@ -6,0 +6,0 @@ checkPromise: Deferred<any> | null; |
@@ -13,20 +13,3 @@ import { Features } from '../../types'; | ||
binary: any; | ||
required: boolean; | ||
url: string; | ||
resource?: string | undefined; | ||
fullResource?: string | undefined; | ||
fullResourceRange?: string[] | undefined; | ||
bootloaderResource?: string | undefined; | ||
bootloaderVersion?: import("../../types").IVersionArray | undefined; | ||
bootloaderRelatedFirmwareVersion?: import("../../types").IVersionArray | undefined; | ||
bootloaderChangelog?: { | ||
"zh-CN": string; | ||
"en-US": string; | ||
} | undefined; | ||
fingerprint: string; | ||
version: import("../../types").IVersionArray; | ||
changelog: { | ||
"zh-CN": string; | ||
"en-US": string; | ||
}; | ||
}>; | ||
@@ -36,4 +19,6 @@ export declare const getSysResourceBinary: (url: string) => Promise<{ | ||
}>; | ||
export declare const getInfo: ({ features, updateType, targetVersion }: GetInfoProps) => import("../../types").IFirmwareReleaseInfo | undefined; | ||
export declare const getInfo: ({ features, updateType, targetVersion }: GetInfoProps) => { | ||
version: import("../../types").IVersionArray; | ||
} | undefined; | ||
export {}; | ||
//# sourceMappingURL=getBinary.d.ts.map |
@@ -0,1 +1,2 @@ | ||
import { Deferred } from '@onekeyfe/hd-shared'; | ||
import { BaseMethod } from './BaseMethod'; | ||
@@ -8,5 +9,6 @@ type Params = { | ||
export default class FirmwareUpdate extends BaseMethod<Params> { | ||
checkPromise: Deferred<any> | null; | ||
init(): void; | ||
postTipMessage: (message: string) => void; | ||
checkDeviceToBootloader(connectId: string | undefined): import("@onekeyfe/hd-shared").Deferred<unknown, any, any>; | ||
checkDeviceToBootloader(connectId: string | undefined): void; | ||
run(): Promise<import("packages/hd-transport/dist").Success>; | ||
@@ -13,0 +15,0 @@ } |
@@ -96,2 +96,4 @@ export { default as searchDevices } from './SearchDevices'; | ||
export { default as lnurlAuth } from './lightning/LnurlAuth'; | ||
export { default as nervosGetAddress } from './nervos/NervosGetAddress'; | ||
export { default as nervosSignTransaction } from './nervos/NervosSignTransaction'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,3 +8,3 @@ import { BaseMethod } from './BaseMethod'; | ||
connectId: string; | ||
deviceType: import("..").IDeviceType | null; | ||
deviceType: import("..").IDeviceType; | ||
path: string; | ||
@@ -11,0 +11,0 @@ session?: string | null | undefined; |
@@ -8,2 +8,11 @@ import { SolanaSignTx as HardwareSolanaSignTx } from '@onekeyfe/hd-transport'; | ||
getVersionRange(): { | ||
model_mini: { | ||
min: string; | ||
}; | ||
model_touch: { | ||
min: string; | ||
}; | ||
classic?: undefined; | ||
mini?: undefined; | ||
} | { | ||
classic: { | ||
@@ -15,5 +24,9 @@ min: string; | ||
}; | ||
model_mini?: undefined; | ||
model_touch?: undefined; | ||
}; | ||
isVersionedTx(hexString: string): boolean; | ||
existsVersionedTx(): boolean; | ||
run(): Promise<SolanaSignedTx | SolanaSignedTx[]>; | ||
} | ||
//# sourceMappingURL=SolSignTransaction.d.ts.map |
@@ -0,5 +1,7 @@ | ||
/// <reference types="node" /> | ||
import { SuiSignTx as HardwareSuiSignTx, TypedCall, SuiSignedTx } from '@onekeyfe/hd-transport'; | ||
import { BaseMethod } from '../BaseMethod'; | ||
import type { TypedResponseMessage } from '../../device/DeviceCommands'; | ||
export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> { | ||
type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx; | ||
export default class SuiSignTransaction extends BaseMethod<SuiSignTx> { | ||
init(): void; | ||
@@ -15,6 +17,7 @@ getVersionRange(): { | ||
supportChunkTransfer(): boolean; | ||
chunkSize: number; | ||
processTxRequest: (typedCall: TypedCall, res: TypedResponseMessage<'SuiSignedTx'> | TypedResponseMessage<'SuiTxRequest'>, data: string, offset?: number) => Promise<SuiSignedTx>; | ||
chunkByteSize: number; | ||
processTxRequest: (typedCall: TypedCall, res: TypedResponseMessage<'SuiSignedTx'> | TypedResponseMessage<'SuiTxRequest'>, data: Buffer, offset?: number) => Promise<SuiSignedTx>; | ||
run(): Promise<SuiSignedTx>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=SuiSignTransaction.d.ts.map |
import type { AssetsMap, ConnectSettings, DeviceTypeMap, Features, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, ITransportStatus, IVersionArray } from '../types'; | ||
export type FirmwareField = 'firmware' | 'firmware-v2' | 'firmware-v4'; | ||
export type FirmwareField = 'firmware' | 'firmware-v2' | 'firmware-v5'; | ||
export type MessageVersion = 'latest' | 'v1'; | ||
@@ -4,0 +4,0 @@ export default class DataManager { |
@@ -80,5 +80,5 @@ /// <reference types="node" /> | ||
checkDeviceId(deviceId: string): boolean; | ||
checkPassphraseState(): Promise<string | false | undefined>; | ||
checkPassphraseStateSafety(passphraseState?: string): Promise<boolean>; | ||
} | ||
export default Device; | ||
//# sourceMappingURL=Device.d.ts.map |
import { Success } from '@onekeyfe/hd-transport'; | ||
import type { Response } from '../params'; | ||
export declare function deviceUpdateBootloader(connectId: string, params: { | ||
export declare function deviceUpdateBootloader(connectId: string, params?: { | ||
binary?: ArrayBuffer; | ||
}): Response<Success>; | ||
//# sourceMappingURL=deviceUpdateBootloader.d.ts.map |
@@ -66,2 +66,4 @@ export type { BTCAddress, BTCGetAddressParams } from './btcGetAddress'; | ||
export type { NexaSignature, NexaSignTransactionParams, NexaSignInputParams, NexaSignOutputParams, } from './nexaSignTransaction'; | ||
export type { NervosAddress, NervosGetAddressParams } from './nervosGetAddress'; | ||
export type { NervosSignedTx, NervosSignTransactionParams } from './nervosSignTransaction'; | ||
//# sourceMappingURL=export.d.ts.map |
import type { PROTO } from '../../constants'; | ||
import type { Params, Response } from '../params'; | ||
type IUpdateType = 'firmware' | 'ble'; | ||
export interface FirmwareUpdateBinaryParams { | ||
binary: ArrayBuffer; | ||
updateType: IUpdateType; | ||
} | ||
@@ -9,3 +11,3 @@ export interface FirmwareUpdateParams { | ||
btcOnly?: boolean; | ||
updateType: 'firmware' | 'ble'; | ||
updateType: IUpdateType; | ||
forcedUpdateRes?: boolean; | ||
@@ -12,0 +14,0 @@ isUpdateBootloader?: boolean; |
@@ -98,2 +98,4 @@ import { off, on, removeAllListeners } from './event'; | ||
import { lnurlAuth } from './lnurlAuth'; | ||
import { nervosGetAddress } from './nervosGetAddress'; | ||
import { nervosSignTransaction } from './nervosSignTransaction'; | ||
export * from './export'; | ||
@@ -206,3 +208,5 @@ export type CoreApi = { | ||
lnurlAuth: typeof lnurlAuth; | ||
nervosGetAddress: typeof nervosGetAddress; | ||
nervosSignTransaction: typeof nervosSignTransaction; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -13,5 +13,6 @@ import type { PROTO } from '../constants'; | ||
deviceId: string | null; | ||
deviceType: IDeviceType; | ||
deviceType: IDeviceType | null; | ||
path: string; | ||
label: string; | ||
bleName: string | null; | ||
name: string; | ||
@@ -35,3 +36,3 @@ error?: typeof undefined; | ||
export type OnekeyFeatures = PROTO.OnekeyFeatures; | ||
export type IDeviceType = 'classic' | 'classic1s' | 'mini' | 'touch' | 'pro'; | ||
export type IDeviceType = 'unknown' | 'classic' | 'classic1s' | 'mini' | 'touch' | 'pro'; | ||
export type IDeviceModel = 'model_classic' | 'model_mini' | 'model_touch'; | ||
@@ -47,7 +48,8 @@ export declare const DeviceModelToTypes: { | ||
export type ITransportStatus = 'valid' | 'outdated'; | ||
export type IVersionRange = { | ||
min: string; | ||
max?: string; | ||
}; | ||
export type DeviceFirmwareRange = { | ||
[deviceType in IDeviceType | IDeviceModel]?: { | ||
min: string; | ||
max?: string; | ||
}; | ||
[deviceType in IDeviceType | IDeviceModel]?: IVersionRange; | ||
}; | ||
@@ -54,0 +56,0 @@ type FeaturesNarrowing = { |
@@ -52,7 +52,8 @@ import type { IDeviceType } from './device'; | ||
}; | ||
type IKnownDevice = Exclude<IDeviceType, 'unknown'>; | ||
export type DeviceTypeMap = { | ||
[k in IDeviceType]: { | ||
[k in IKnownDevice]: { | ||
firmware: IFirmwareReleaseInfo[]; | ||
'firmware-v2'?: IFirmwareReleaseInfo[]; | ||
'firmware-v4'?: IFirmwareReleaseInfo[]; | ||
'firmware-v5'?: IFirmwareReleaseInfo[]; | ||
ble: IBLEFirmwareReleaseInfo[]; | ||
@@ -79,2 +80,3 @@ }; | ||
} & DeviceTypeMap; | ||
export {}; | ||
//# sourceMappingURL=settings.d.ts.map |
import { DeviceCommands } from '../device/DeviceCommands'; | ||
import type { Features, IDeviceModel, IDeviceType, IVersionArray, SupportFeatureType } from '../types'; | ||
import type { Features, SupportFeatureType } from '../types'; | ||
import { FirmwareField, MessageVersion } from '../data-manager/DataManager'; | ||
import { Device } from '../device/Device'; | ||
export declare const getDeviceModel: (features?: Features) => IDeviceModel; | ||
export declare const getDeviceType: (features?: Features) => IDeviceType; | ||
export declare const getDeviceTypeOnBootloader: (features?: Features) => IDeviceType; | ||
export declare const getDeviceTypeByBleName: (name?: string) => IDeviceType | null; | ||
export declare const getDeviceTypeByDeviceId: (deviceId?: string) => IDeviceType; | ||
export declare const getDeviceUUID: (features: Features) => string; | ||
export declare const getDeviceLabel: (features: Features) => string; | ||
export declare const getDeviceFirmwareVersion: (features: Features | undefined) => IVersionArray; | ||
export declare const getDeviceBLEFirmwareVersion: (features: Features) => IVersionArray | null; | ||
export declare const getDeviceBootloaderVersion: (features: Features) => IVersionArray; | ||
export declare const getSupportMessageVersion: (features: Features | undefined) => { | ||
@@ -16,0 +6,0 @@ messages: JSON; |
import type { IDeviceType } from '../types'; | ||
export declare const getT1Data: () => { | ||
default: { | ||
name: string; | ||
hex: string; | ||
}; | ||
original: { | ||
name: string; | ||
hex: string; | ||
}; | ||
circleweb: { | ||
name: string; | ||
hex: string; | ||
}; | ||
circuit: { | ||
name: string; | ||
hex: string; | ||
}; | ||
starweb: { | ||
name: string; | ||
hex: string; | ||
}; | ||
stars: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bitcoin_b2: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bitcoin_shade: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bitcoin_b: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bitcoin_full: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bitcat: { | ||
name: string; | ||
hex: string; | ||
}; | ||
nyancat: { | ||
name: string; | ||
hex: string; | ||
}; | ||
coffee: { | ||
name: string; | ||
hex: string; | ||
}; | ||
flower: { | ||
name: string; | ||
hex: string; | ||
}; | ||
saturn: { | ||
name: string; | ||
hex: string; | ||
}; | ||
jupiter: { | ||
name: string; | ||
hex: string; | ||
}; | ||
einstein: { | ||
name: string; | ||
hex: string; | ||
}; | ||
piggy: { | ||
name: string; | ||
hex: string; | ||
}; | ||
honeybadger: { | ||
name: string; | ||
hex: string; | ||
}; | ||
dragon: { | ||
name: string; | ||
hex: string; | ||
}; | ||
narwal: { | ||
name: string; | ||
hex: string; | ||
}; | ||
rabbit: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bunny: { | ||
name: string; | ||
hex: string; | ||
}; | ||
rooster: { | ||
name: string; | ||
hex: string; | ||
}; | ||
genesis: { | ||
name: string; | ||
hex: string; | ||
}; | ||
my_bank: { | ||
name: string; | ||
hex: string; | ||
}; | ||
candle: { | ||
name: string; | ||
hex: string; | ||
}; | ||
ancap: { | ||
name: string; | ||
hex: string; | ||
}; | ||
anonymous: { | ||
name: string; | ||
hex: string; | ||
}; | ||
mushroom: { | ||
name: string; | ||
hex: string; | ||
}; | ||
invader: { | ||
name: string; | ||
hex: string; | ||
}; | ||
mtgox: { | ||
name: string; | ||
hex: string; | ||
}; | ||
electrum: { | ||
name: string; | ||
hex: string; | ||
}; | ||
mycelium: { | ||
name: string; | ||
hex: string; | ||
}; | ||
ethereum: { | ||
name: string; | ||
hex: string; | ||
}; | ||
litecoin: { | ||
name: string; | ||
hex: string; | ||
}; | ||
myetherwallet: { | ||
name: string; | ||
hex: string; | ||
}; | ||
zcash: { | ||
name: string; | ||
hex: string; | ||
}; | ||
dash: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bitcoin_cash: { | ||
name: string; | ||
hex: string; | ||
}; | ||
bitcoin_gold: { | ||
name: string; | ||
hex: string; | ||
}; | ||
vertcoin: { | ||
name: string; | ||
hex: string; | ||
}; | ||
namecoin: { | ||
name: string; | ||
hex: string; | ||
}; | ||
monacoin: { | ||
name: string; | ||
hex: string; | ||
}; | ||
doge: { | ||
name: string; | ||
hex: string; | ||
}; | ||
digibyte: { | ||
name: string; | ||
hex: string; | ||
}; | ||
decred: { | ||
name: string; | ||
hex: string; | ||
}; | ||
multibit: { | ||
name: string; | ||
hex: string; | ||
}; | ||
reddit: { | ||
name: string; | ||
hex: string; | ||
}; | ||
hacker: { | ||
name: string; | ||
hex: string; | ||
}; | ||
polis: { | ||
name: string; | ||
hex: string; | ||
}; | ||
carlos: { | ||
name: string; | ||
hex: string; | ||
}; | ||
xrc: { | ||
name: string; | ||
hex: string; | ||
}; | ||
type IScreenData = { | ||
name: string; | ||
hex: string; | ||
}; | ||
export declare const getTouchData: () => { | ||
'wallpaper-1': { | ||
name: string; | ||
hex: string; | ||
}; | ||
'wallpaper-2': { | ||
name: string; | ||
hex: string; | ||
}; | ||
'wallpaper-3': { | ||
name: string; | ||
hex: string; | ||
}; | ||
'wallpaper-4': { | ||
name: string; | ||
hex: string; | ||
}; | ||
}; | ||
export declare const getHomeScreenHex: (deviceType: IDeviceType, name: string) => any; | ||
export declare const getT1Data: () => Record<string, IScreenData>; | ||
export declare const getTouchData: () => Record<string, IScreenData>; | ||
export declare const getHomeScreenHex: (deviceType: IDeviceType, name: string) => string; | ||
export {}; | ||
//# sourceMappingURL=homescreen.d.ts.map |
export * from './assets'; | ||
export * from './versionUtils'; | ||
export * from './patch'; | ||
export { getDeviceType, getDeviceTypeByBleName, getDeviceTypeByDeviceId, getDeviceUUID, getDeviceLabel, getFirmwareUpdateField, getDeviceFirmwareVersion, getDeviceBootloaderVersion, supportInputPinOnSoftware, } from './deviceFeaturesUtils'; | ||
export { getHDPath, getScriptType, getOutputScriptType } from '../api/helpers/pathUtils'; | ||
export { getDeviceTypeByBleName, getDeviceType, getDeviceBleName, getDeviceUUID, getDeviceLabel, getMethodVersionRange, } from './deviceInfoUtils'; | ||
export { getDeviceBoardloaderVersion, getDeviceBootloaderVersion, getDeviceFirmwareVersion, getDeviceBLEFirmwareVersion, } from './deviceVersionUtils'; | ||
export { getFirmwareUpdateField, supportInputPinOnSoftware } from './deviceFeaturesUtils'; | ||
export { checkNeedUpdateBootForTouch, checkNeedUpdateBootForClassicAndMini, } from '../api/firmware/updateBootloader'; | ||
export { getLogger, enableLog, LoggerNames, getLog, setLoggerPostMessage } from './logger'; | ||
export { getHDPath, getScriptType, getOutputScriptType } from '../api/helpers/pathUtils'; | ||
export declare const isBleConnect: (env: string) => boolean; | ||
export { getHomeScreenHex } from './homescreen'; | ||
export declare const wait: (ms: number) => Promise<unknown>; | ||
export declare const isBleConnect: (env: string) => boolean; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@onekeyfe/hd-core", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"description": "> TODO: description", | ||
@@ -28,4 +28,4 @@ "author": "OneKey", | ||
"dependencies": { | ||
"@onekeyfe/hd-shared": "^1.0.0-alpha.1", | ||
"@onekeyfe/hd-transport": "^1.0.0-alpha.1", | ||
"@onekeyfe/hd-shared": "^1.0.0-alpha.2", | ||
"@onekeyfe/hd-transport": "^1.0.0-alpha.2", | ||
"axios": "^0.27.2", | ||
@@ -48,3 +48,3 @@ "bignumber.js": "^9.0.2", | ||
}, | ||
"gitHead": "d905e89754333ccd9ea40e4b65d72d224c676297" | ||
"gitHead": "395ac8bf3a84ecfc39fca6e3184f811f67fe0edc" | ||
} |
@@ -8,2 +8,3 @@ import { GetAddress } from '@onekeyfe/hd-transport'; | ||
import { getCoinInfo } from './helpers/btcParamsUtils'; | ||
import { getBitcoinForkVersionRange } from './helpers/versionLimit'; | ||
@@ -58,2 +59,6 @@ export default class BTCGetAddress extends BaseMethod<GetAddress[]> { | ||
getVersionRange() { | ||
return getBitcoinForkVersionRange(this.params.map(param => param.coin_name)); | ||
} | ||
async run() { | ||
@@ -60,0 +65,0 @@ const responses: BTCAddress[] = []; |
@@ -9,2 +9,3 @@ import { GetPublicKey } from '@onekeyfe/hd-transport'; | ||
import { BTCPublicKey } from '../../types/api/btcGetPublicKey'; | ||
import { getBitcoinForkVersionRange } from './helpers/versionLimit'; | ||
@@ -62,2 +63,6 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> { | ||
getVersionRange() { | ||
return getBitcoinForkVersionRange(this.params.map(param => param.coin_name)); | ||
} | ||
async run() { | ||
@@ -64,0 +69,0 @@ const responses: BTCPublicKey[] = []; |
@@ -8,2 +8,3 @@ import { SignMessage } from '@onekeyfe/hd-transport'; | ||
import { getCoinAndScriptType } from './helpers/btcParamsUtils'; | ||
import { getBitcoinForkVersionRange } from './helpers/versionLimit'; | ||
@@ -37,2 +38,6 @@ export default class BTCSignMessage extends BaseMethod<SignMessage> { | ||
getVersionRange() { | ||
return getBitcoinForkVersionRange([this.params.coin_name]); | ||
} | ||
async run() { | ||
@@ -39,0 +44,0 @@ const res = await this.device.commands.typedCall('SignMessage', 'MessageSignature', { |
@@ -17,2 +17,3 @@ import { TxInputType, TxOutputType } from '@onekeyfe/hd-transport'; | ||
import { getCoinInfo } from './helpers/btcParamsUtils'; | ||
import { getBitcoinForkVersionRange } from './helpers/versionLimit'; | ||
@@ -124,2 +125,6 @@ type Params = { | ||
getVersionRange() { | ||
return getBitcoinForkVersionRange([this.params.coinName]); | ||
} | ||
async run() { | ||
@@ -126,0 +131,0 @@ const { device, params } = this; |
@@ -8,2 +8,3 @@ import { VerifyMessage } from '@onekeyfe/hd-transport'; | ||
import { getCoinInfo } from './helpers/btcParamsUtils'; | ||
import { getBitcoinForkVersionRange } from './helpers/versionLimit'; | ||
@@ -35,2 +36,6 @@ export default class BTCVerifyMessage extends BaseMethod<VerifyMessage> { | ||
getVersionRange() { | ||
return getBitcoinForkVersionRange([this.params.coin_name]); | ||
} | ||
async run() { | ||
@@ -37,0 +42,0 @@ const res = await this.device.commands.typedCall('VerifyMessage', 'Success', { |
@@ -6,4 +6,3 @@ import axios from 'axios'; | ||
import { UI_REQUEST } from '../constants/ui-request'; | ||
import { getDeviceType } from '../utils'; | ||
import { getDeviceFirmwareVersion } from '../utils/deviceFeaturesUtils'; | ||
import { getDeviceType, getDeviceFirmwareVersion } from '../utils'; | ||
import { DeviceModelToTypes } from '../types'; | ||
@@ -42,3 +41,3 @@ | ||
let shouldUpdate = false; | ||
if (deviceType === 'touch') { | ||
if (DeviceModelToTypes.model_touch.includes(deviceType)) { | ||
if (semver.gte(willUpdateFirmwareVersion, TouchNeedUpdateVersion) && isOldVersionBridge) { | ||
@@ -45,0 +44,0 @@ shouldUpdate = true; |
@@ -7,7 +7,6 @@ import { Deferred } from '@onekeyfe/hd-shared'; | ||
import { updateResources } from '../firmware/uploadFirmware'; | ||
import { getDeviceType } from '../../utils'; | ||
import { getDeviceType, getDeviceFirmwareVersion } from '../../utils'; | ||
import { createUiMessage } from '../../events/ui-request'; | ||
import type { KnownDevice, Features } from '../../types'; | ||
import { DataManager } from '../../data-manager'; | ||
import { getDeviceFirmwareVersion } from '../../utils/deviceFeaturesUtils'; | ||
@@ -14,0 +13,0 @@ export default class DeviceFullyUploadResource extends BaseMethod { |
@@ -7,8 +7,10 @@ import { Deferred, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared'; | ||
import { createUiMessage } from '../../events/ui-request'; | ||
import type { Features, KnownDevice } from '../../types'; | ||
import { DeviceModelToTypes } from '../../types'; | ||
import { DataManager } from '../../data-manager'; | ||
import { checkBootloaderLength, checkNeedUpdateBootForTouch } from '../firmware/updateBootloader'; | ||
import type { Device } from '../../device/Device'; | ||
import { getDeviceType } from '../../utils'; | ||
import type { Device } from '../../device/Device'; | ||
import type { Features, KnownDevice } from '../../types'; | ||
export default class DeviceUpdateBootloader extends BaseMethod { | ||
@@ -78,3 +80,3 @@ checkPromise: Deferred<any> | null = null; | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'touch') { | ||
if (DeviceModelToTypes.model_touch.includes(deviceType)) { | ||
return this.updateTouchBootloader(device, features); | ||
@@ -81,0 +83,0 @@ } |
@@ -7,3 +7,3 @@ import semver from 'semver'; | ||
import { TypedResponseMessage } from '../../device/DeviceCommands'; | ||
import { DeviceUploadResourceParams } from '../../types'; | ||
import { DeviceModelToTypes, DeviceUploadResourceParams } from '../../types'; | ||
import { BaseMethod } from '../BaseMethod'; | ||
@@ -13,4 +13,3 @@ import { validateParams } from '../helpers/paramsValidator'; | ||
import { createUiMessage, UI_REQUEST } from '../../events'; | ||
import { getDeviceType } from '../../utils'; | ||
import { getDeviceFirmwareVersion } from '../../utils/deviceFeaturesUtils'; | ||
import { getDeviceType, getDeviceFirmwareVersion } from '../../utils'; | ||
import { PROTO } from '../../constants'; | ||
@@ -35,3 +34,3 @@ | ||
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.'); | ||
if (deviceType !== 'touch') { | ||
if (!DeviceModelToTypes.model_touch.includes(deviceType)) { | ||
throw ERRORS.TypedError(HardwareErrorCode.CallMethodError, 'Device Not Support Upload NFT'); | ||
@@ -38,0 +37,0 @@ } |
@@ -16,3 +16,3 @@ import semver from 'semver'; | ||
import { formatAnyHex } from '../helpers/hexUtils'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils/deviceFeaturesUtils'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils'; | ||
import { | ||
@@ -19,0 +19,0 @@ DeviceModelToTypes, |
@@ -5,3 +5,3 @@ import { MessageResponse, TypedCall } from '@onekeyfe/hd-transport'; | ||
import { Device } from '../../../device/Device'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils/deviceFeaturesUtils'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils'; | ||
@@ -8,0 +8,0 @@ export const signTypedHash = async ({ |
@@ -5,3 +5,3 @@ import { MessageResponse, TypedCall } from '@onekeyfe/hd-transport'; | ||
import { Device } from '../../../device/Device'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils/deviceFeaturesUtils'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils'; | ||
@@ -8,0 +8,0 @@ export const signTypedHash = async ({ |
import ByteBuffer from 'bytebuffer'; | ||
import semver from 'semver'; | ||
import { DeviceModelToTypes, Features } from '../../types'; | ||
import { getDeviceType } from '../../utils'; | ||
import { | ||
getDeviceBootloaderVersion, | ||
getDeviceFirmwareVersion, | ||
} from '../../utils/deviceFeaturesUtils'; | ||
import { getDeviceType, getDeviceBootloaderVersion, getDeviceFirmwareVersion } from '../../utils'; | ||
import { DataManager } from '../../data-manager'; | ||
@@ -10,0 +6,0 @@ import { shouldUpdateBootloaderForClassicAndMini } from './bootloaderHelper'; |
@@ -6,3 +6,3 @@ import semver from 'semver'; | ||
import { Success } from '@onekeyfe/hd-transport'; | ||
import { wait } from '../../utils/index'; | ||
import { wait, getDeviceBootloaderVersion, getDeviceType } from '../../utils'; | ||
import { DEVICE, CoreMessage, createUiMessage, UI_REQUEST } from '../../events'; | ||
@@ -12,5 +12,4 @@ import { PROTO } from '../../constants'; | ||
import type { TypedCall, TypedResponseMessage } from '../../device/DeviceCommands'; | ||
import { KnownDevice } from '../../types'; | ||
import { DeviceModelToTypes, KnownDevice } from '../../types'; | ||
import { bytesToHex } from '../helpers/hexUtils'; | ||
import { getDeviceBootloaderVersion, getDeviceModel } from '../../utils/deviceFeaturesUtils'; | ||
import { DataManager } from '../../data-manager'; | ||
@@ -71,4 +70,4 @@ import { DevicePool } from '../../device/DevicePool'; | ||
) => { | ||
const deviceModel = getDeviceModel(device.features); | ||
if (deviceModel === 'model_mini') { | ||
const deviceType = getDeviceType(device.features); | ||
if (DeviceModelToTypes.model_mini.includes(deviceType)) { | ||
postConfirmationMessage(device); | ||
@@ -95,3 +94,3 @@ postProgressTip(device, 'ConfirmOnDevice', postMessage); | ||
if (deviceModel === 'model_touch') { | ||
if (DeviceModelToTypes.model_touch.includes(deviceType)) { | ||
if (device.features) { | ||
@@ -98,0 +97,0 @@ const bootloaderVersion = getDeviceBootloaderVersion(device.features); |
@@ -1,2 +0,8 @@ | ||
import { ERRORS, HardwareErrorCode, HardwareError, createDeferred } from '@onekeyfe/hd-shared'; | ||
import { | ||
ERRORS, | ||
HardwareErrorCode, | ||
HardwareError, | ||
createDeferred, | ||
Deferred, | ||
} from '@onekeyfe/hd-shared'; | ||
import { UI_REQUEST } from '../constants/ui-request'; | ||
@@ -25,2 +31,4 @@ import { BaseMethod } from './BaseMethod'; | ||
export default class FirmwareUpdate extends BaseMethod<Params> { | ||
checkPromise: Deferred<any> | null = null; | ||
init() { | ||
@@ -37,11 +45,5 @@ this.notAllowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.INITIALIZE]; | ||
{ name: 'binary', type: 'buffer' }, | ||
{ name: 'updateType', type: 'string', required: true }, | ||
]); | ||
if (!payload.updateType) { | ||
throw ERRORS.TypedError( | ||
HardwareErrorCode.CallMethodInvalidParameter, | ||
'updateType is required' | ||
); | ||
} | ||
this.params = { updateType: payload.updateType }; | ||
@@ -76,7 +78,7 @@ | ||
checkDeviceToBootloader(connectId: string | undefined) { | ||
const checkPromise = createDeferred(); | ||
this.checkPromise = createDeferred(); | ||
const env = DataManager.getSettings('env'); | ||
const isBleReconnect = connectId && DataManager.isBleConnect(env); | ||
Log.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect); | ||
Log.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect); | ||
@@ -96,3 +98,3 @@ // check device goto bootloader mode | ||
clearInterval(intervalTimer); | ||
checkPromise?.resolve(true); | ||
this.checkPromise?.resolve(true); | ||
} | ||
@@ -115,3 +117,3 @@ } catch (e) { | ||
clearInterval(intervalTimer); | ||
checkPromise?.resolve(true); | ||
this.checkPromise?.resolve(true); | ||
} | ||
@@ -125,9 +127,7 @@ } | ||
setTimeout(() => { | ||
if (checkPromise) { | ||
if (this.checkPromise) { | ||
clearInterval(intervalTimer); | ||
checkPromise.reject(new Error()); | ||
this.checkPromise.reject(new Error()); | ||
} | ||
}, 30000); | ||
return checkPromise; | ||
} | ||
@@ -156,3 +156,3 @@ | ||
this.postTipMessage('GoToBootloaderSuccess'); | ||
const checkPromise = this.checkDeviceToBootloader(this.payload.connectId); | ||
this.checkDeviceToBootloader(this.payload.connectId); | ||
@@ -164,8 +164,9 @@ // force clean classic device cache so that the device can initialize again | ||
delete DevicePool.devicesCache['']; | ||
await checkPromise?.promise; | ||
await this.checkPromise?.promise; | ||
this.checkPromise = null; | ||
/** | ||
* Touch 1 with bootloader v2.5.0 issue: BLE chip need more time for looking up name, here change the delay time to 3000ms after rebooting. | ||
*/ | ||
await wait(deviceType === 'touch' ? 3000 : 1500); | ||
const isTouch = DeviceModelToTypes.model_touch.includes(deviceType); | ||
await wait(isTouch ? 3000 : 1500); | ||
} catch (e) { | ||
@@ -193,2 +194,3 @@ if (e instanceof HardwareError) { | ||
} | ||
this.postTipMessage('DownloadFirmware'); | ||
const firmware = await getBinary({ | ||
@@ -200,2 +202,3 @@ features: device.features, | ||
binary = firmware.binary; | ||
this.postTipMessage('DownloadFirmwareSuccess'); | ||
} | ||
@@ -206,2 +209,4 @@ } catch (err) { | ||
await this.device.acquire(); | ||
return uploadFirmware( | ||
@@ -208,0 +213,0 @@ params.updateType, |
@@ -15,7 +15,13 @@ import { | ||
import { updateResources, uploadFirmware } from './firmware/uploadFirmware'; | ||
import { getDeviceType, getDeviceUUID, wait, getLogger, LoggerNames } from '../utils'; | ||
import { | ||
getDeviceType, | ||
getDeviceUUID, | ||
wait, | ||
getLogger, | ||
LoggerNames, | ||
getDeviceFirmwareVersion, | ||
} from '../utils'; | ||
import { createUiMessage } from '../events/ui-request'; | ||
import { DeviceModelToTypes } from '../types'; | ||
import { DataManager } from '../data-manager'; | ||
import { getDeviceFirmwareVersion } from '../utils/deviceFeaturesUtils'; | ||
@@ -250,3 +256,4 @@ import type { KnownDevice, Features } from '../types'; | ||
*/ | ||
await wait(deviceType === 'touch' ? 3000 : 1500); | ||
const isTouch = DeviceModelToTypes.model_touch.includes(deviceType); | ||
await wait(isTouch ? 3000 : 1500); | ||
} catch (e) { | ||
@@ -253,0 +260,0 @@ if (e instanceof HardwareError) { |
@@ -117,2 +117,6 @@ export { default as searchDevices } from './SearchDevices'; | ||
export { default as nostrSignSchnorr } from './nostr/NostrSignSchnorr'; | ||
export { default as lnurlAuth } from './lightning/LnurlAuth'; | ||
export { default as nervosGetAddress } from './nervos/NervosGetAddress'; | ||
export { default as nervosSignTransaction } from './nervos/NervosSignTransaction'; |
@@ -40,2 +40,13 @@ import { SolanaSignTx as HardwareSolanaSignTx } from '@onekeyfe/hd-transport'; | ||
getVersionRange() { | ||
if (this.existsVersionedTx()) { | ||
return { | ||
model_mini: { | ||
min: '3.1.0', | ||
}, | ||
model_touch: { | ||
min: '4.3.0', | ||
}, | ||
}; | ||
} | ||
return { | ||
@@ -51,2 +62,26 @@ classic: { | ||
isVersionedTx(hexString: string) { | ||
if (hexString.length === 0) return false; | ||
try { | ||
const cleanHexString = hexString.startsWith('0x') ? hexString.slice(2) : hexString; | ||
const binary = parseInt(cleanHexString[0], 16).toString(2); | ||
// Check highest bit | ||
return binary[0] === '1'; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
existsVersionedTx() { | ||
for (let i = 0; i < this.params.length; i++) { | ||
const param = this.params[i]; | ||
const { raw_tx } = param; | ||
if (this.isVersionedTx(raw_tx)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
async run() { | ||
@@ -53,0 +88,0 @@ const responses: SolanaSignedTx[] = []; |
@@ -8,7 +8,9 @@ import { SuiSignTx as HardwareSuiSignTx, TypedCall, SuiSignedTx } from '@onekeyfe/hd-transport'; | ||
import { formatAnyHex } from '../helpers/hexUtils'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils/deviceFeaturesUtils'; | ||
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils'; | ||
import { DeviceModelToTypes } from '../../types'; | ||
import type { TypedResponseMessage } from '../../device/DeviceCommands'; | ||
export default class SuiSignTransaction extends BaseMethod<HardwareSuiSignTx> { | ||
type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx; | ||
export default class SuiSignTransaction extends BaseMethod<SuiSignTx> { | ||
init() { | ||
@@ -63,3 +65,3 @@ this.checkDeviceId = true; | ||
chunkSize = 1024; | ||
chunkByteSize = 1024; | ||
@@ -69,3 +71,3 @@ processTxRequest = async ( | ||
res: TypedResponseMessage<'SuiSignedTx'> | TypedResponseMessage<'SuiTxRequest'>, | ||
data: string, | ||
data: Buffer, | ||
offset = 0 | ||
@@ -84,6 +86,6 @@ ): Promise<SuiSignedTx> => { | ||
const payload = data.slice(offset, offset + data_length * 2); | ||
const payload = data.subarray(offset, offset + data_length); | ||
const newOffset = offset + payload.length; | ||
const resourceAckParams = { | ||
data_chunk: payload, | ||
data_chunk: payload.toString('hex'), | ||
}; | ||
@@ -100,14 +102,13 @@ | ||
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands()); | ||
const dataLength = this.params.raw_tx.length / 2; | ||
let offset = 0; | ||
let data = ''; | ||
let data: Buffer; | ||
if (this.supportChunkTransfer()) { | ||
offset = this.chunkSize; | ||
data = this.params.raw_tx; | ||
offset = this.chunkByteSize; | ||
data = Buffer.from(this.params.raw_tx, 'hex'); | ||
this.params = { | ||
address_n: this.params.address_n, | ||
raw_tx: '', | ||
data_initial_chunk: this.params.raw_tx.slice(0, this.chunkSize * 2), | ||
data_length: dataLength, | ||
data_initial_chunk: data.subarray(0, this.chunkByteSize).toString('hex'), | ||
data_length: data.length, | ||
}; | ||
@@ -114,0 +115,0 @@ } |
@@ -13,6 +13,10 @@ import semver from 'semver'; | ||
getDeviceFirmwareVersion, | ||
getDeviceModel, | ||
getDeviceType, | ||
supportNewPassphrase, | ||
} from '../utils/deviceFeaturesUtils'; | ||
enableLog, | ||
getLogger, | ||
LoggerNames, | ||
setLoggerPostMessage, | ||
wait, | ||
getMethodVersionRange, | ||
} from '../utils'; | ||
import { supportNewPassphrase } from '../utils/deviceFeaturesUtils'; | ||
import { Device, DeviceEvents, InitOptions, RunOptions } from '../device/Device'; | ||
@@ -23,3 +27,2 @@ import { DeviceList } from '../device/DeviceList'; | ||
import { DataManager } from '../data-manager'; | ||
import { enableLog, getLogger, LoggerNames, setLoggerPostMessage, wait } from '../utils'; | ||
import { | ||
@@ -148,10 +151,7 @@ CORE_EVENT, | ||
// check firmware version | ||
const deviceType = getDeviceType(device.features); | ||
const deviceModel = getDeviceModel(device.features); | ||
const versionRangeType = method.getVersionRange()[deviceType]; | ||
const versionRangeModel = method.getVersionRange()[deviceModel]; | ||
const versionRange = getMethodVersionRange( | ||
device.features, | ||
type => method.getVersionRange()[type] | ||
); | ||
// Type has a higher priority than Model | ||
const versionRange = versionRangeType ?? versionRangeModel; | ||
if (device.features) { | ||
@@ -242,3 +242,3 @@ await DataManager.checkAndReloadData(); | ||
// Check to see if it is safe to use Passphrase | ||
checkPassphraseSafety(method, device.features); | ||
checkPassphraseEnableState(method, device.features); | ||
@@ -261,8 +261,10 @@ if (device.hasUsePassphrase() && method.useDevicePassphraseState) { | ||
// Check Device passphrase State | ||
const passphraseState = await device.checkPassphraseState(); | ||
const passphraseStateSafety = await device.checkPassphraseStateSafety( | ||
method.payload?.passphraseState | ||
); | ||
// Double check, handles the special case of Touch/Pro | ||
checkPassphraseSafety(method, device.features); | ||
checkPassphraseEnableState(method, device.features); | ||
if (passphraseState) { | ||
if (!passphraseStateSafety) { | ||
DevicePool.clearDeviceCache(method.payload.connectId); | ||
@@ -564,3 +566,3 @@ return Promise.reject( | ||
const checkPassphraseSafety = (method: BaseMethod, features?: Features) => { | ||
const checkPassphraseEnableState = (method: BaseMethod, features?: Features) => { | ||
if (!method.useDevicePassphraseState) return; | ||
@@ -567,0 +569,0 @@ |
@@ -5,4 +5,4 @@ import axios from 'axios'; | ||
import MessagesLegacyV1JSON from '../data/messages/messages_legacy_v1.json'; | ||
import { getTimeStamp } from '../utils'; | ||
import { | ||
getTimeStamp, | ||
getDeviceBLEFirmwareVersion, | ||
@@ -12,3 +12,3 @@ getDeviceFirmwareVersion, | ||
getFirmwareUpdateField, | ||
} from '../utils/deviceFeaturesUtils'; | ||
} from '../utils'; | ||
@@ -29,3 +29,3 @@ import type { | ||
export type FirmwareField = 'firmware' | 'firmware-v2' | 'firmware-v4'; | ||
export type FirmwareField = 'firmware' | 'firmware-v2' | 'firmware-v5'; | ||
@@ -71,2 +71,4 @@ export type MessageVersion = 'latest' | 'v1'; | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return 'unknown'; | ||
const deviceFirmwareVersion = getDeviceFirmwareVersion(features); | ||
@@ -118,2 +120,3 @@ if (features.firmware_present === false) { | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return undefined; | ||
@@ -134,2 +137,3 @@ if (deviceType !== 'pro' && deviceType !== 'touch') return undefined; | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return undefined; | ||
@@ -149,2 +153,3 @@ if (deviceType !== 'pro' && deviceType !== 'touch') return undefined; | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return undefined; | ||
@@ -163,2 +168,3 @@ const firmwareUpdateField = getFirmwareUpdateField({ | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return undefined; | ||
@@ -180,2 +186,4 @@ if (!DeviceModelToTypes.model_mini.includes(deviceType)) return undefined; | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return []; | ||
const deviceFirmwareVersion = getDeviceFirmwareVersion(features); | ||
@@ -201,2 +209,4 @@ | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return undefined; | ||
const firmwareUpdateField = getFirmwareUpdateField({ | ||
@@ -223,2 +233,4 @@ features, | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return 'unknown'; | ||
const deviceBLEFirmwareVersion = getDeviceBLEFirmwareVersion(features); | ||
@@ -238,2 +250,4 @@ | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return []; | ||
const deviceBLEFirmwareVersion = getDeviceBLEFirmwareVersion(features); | ||
@@ -252,2 +266,4 @@ | ||
const deviceType = getDeviceType(features); | ||
if (deviceType === 'unknown') return undefined; | ||
const targetDeviceConfigList = this.deviceMap[deviceType]?.ble ?? []; | ||
@@ -254,0 +270,0 @@ return findLatestRelease(targetDeviceConfigList); |
@@ -42,3 +42,4 @@ [ | ||
{ "name": "Zcash", "label": "ZEC", "slip44": 133 }, | ||
{ "name": "Zcash Testnet", "label": "TAZ", "slip44": 1 } | ||
{ "name": "Zcash Testnet", "label": "TAZ", "slip44": 1 }, | ||
{ "name": "Neurai", "label": "XNA", "slip44": 1900 } | ||
] |
@@ -12,9 +12,11 @@ import EventEmitter from 'events'; | ||
getDeviceBLEFirmwareVersion, | ||
getDeviceBleName, | ||
getDeviceFirmwareVersion, | ||
getDeviceLabel, | ||
getDeviceType, | ||
getDeviceTypeOnBootloader, | ||
getDeviceUUID, | ||
getPassphraseStateWithRefreshDeviceInfo, | ||
} from '../utils/deviceFeaturesUtils'; | ||
getLogger, | ||
LoggerNames, | ||
} from '../utils'; | ||
import { getPassphraseStateWithRefreshDeviceInfo } from '../utils/deviceFeaturesUtils'; | ||
@@ -29,3 +31,2 @@ import type DeviceConnector from './DeviceConnector'; | ||
import { PROTO } from '../constants'; | ||
import { getLogger, LoggerNames } from '../utils'; | ||
import { DataManager } from '../data-manager'; | ||
@@ -138,3 +139,7 @@ import TransportManager from '../data-manager/TransportManager'; | ||
const env = DataManager.getSettings('env'); | ||
const deviceType = getDeviceType(this.features); | ||
const bleName = getDeviceBleName(this.features); | ||
const label = getDeviceLabel(this.features); | ||
return { | ||
@@ -145,13 +150,9 @@ /** Android uses Mac address, iOS uses uuid, USB uses uuid */ | ||
uuid: getDeviceUUID(this.features), | ||
deviceType: this.features.bootloader_mode | ||
? getDeviceTypeOnBootloader(this.features) | ||
: getDeviceType(this.features), | ||
deviceType, | ||
/** ID for current seeds, will clear after replace a new seed at device */ | ||
deviceId: this.features.device_id || null, | ||
path: this.originalDescriptor.path, | ||
name: | ||
this.features.ble_name || | ||
this.features.label || | ||
`OneKey ${getDeviceType(this.features).toUpperCase()}`, | ||
label: getDeviceLabel(this.features), | ||
bleName, | ||
name: bleName || label || `OneKey ${deviceType?.toUpperCase()}`, | ||
label: label || 'OneKey', | ||
mode: this.getMode(), | ||
@@ -593,3 +594,3 @@ features: this.features, | ||
async checkPassphraseState() { | ||
async checkPassphraseStateSafety(passphraseState?: string) { | ||
if (!this.features) return false; | ||
@@ -599,6 +600,8 @@ const newState = await getPassphraseStateWithRefreshDeviceInfo(this); | ||
// When exists passphraseState, check passphraseState | ||
if (this.passphraseState && this.passphraseState !== newState) { | ||
if (passphraseState && passphraseState !== newState) { | ||
this.clearInternalState(); | ||
return newState; | ||
return false; | ||
} | ||
return true; | ||
} | ||
@@ -605,0 +608,0 @@ } |
@@ -287,2 +287,7 @@ import { EventEmitter } from 'events'; | ||
call({ ...params, connectId, deviceId, method: 'lnurlAuth' }), | ||
nervosGetAddress: (connectId, deviceId, params) => | ||
call({ ...params, connectId, deviceId, method: 'nervosGetAddress' }), | ||
nervosSignTransaction: (connectId, deviceId, params) => | ||
call({ ...params, connectId, deviceId, method: 'nervosSignTransaction' }), | ||
}); |
@@ -6,5 +6,5 @@ import { Success } from '@onekeyfe/hd-transport'; | ||
connectId: string, | ||
params: { | ||
params?: { | ||
binary?: ArrayBuffer; | ||
} | ||
): Response<Success>; |
@@ -149,1 +149,4 @@ export type { BTCAddress, BTCGetAddressParams } from './btcGetAddress'; | ||
} from './nexaSignTransaction'; | ||
export type { NervosAddress, NervosGetAddressParams } from './nervosGetAddress'; | ||
export type { NervosSignedTx, NervosSignTransactionParams } from './nervosSignTransaction'; |
import type { PROTO } from '../../constants'; | ||
import type { Params, Response } from '../params'; | ||
type IUpdateType = 'firmware' | 'ble'; | ||
export interface FirmwareUpdateBinaryParams { | ||
binary: ArrayBuffer; | ||
updateType: IUpdateType; | ||
} | ||
@@ -11,3 +14,3 @@ | ||
btcOnly?: boolean; | ||
updateType: 'firmware' | 'ble'; | ||
updateType: IUpdateType; | ||
forcedUpdateRes?: boolean; | ||
@@ -14,0 +17,0 @@ isUpdateBootloader?: boolean; |
@@ -123,2 +123,4 @@ import { off, on, removeAllListeners } from './event'; | ||
import { lnurlAuth } from './lnurlAuth'; | ||
import { nervosGetAddress } from './nervosGetAddress'; | ||
import { nervosSignTransaction } from './nervosSignTransaction'; | ||
@@ -329,2 +331,8 @@ export * from './export'; | ||
lnurlAuth: typeof lnurlAuth; | ||
/** | ||
* Nervos Network | ||
*/ | ||
nervosGetAddress: typeof nervosGetAddress; | ||
nervosSignTransaction: typeof nervosSignTransaction; | ||
}; |
@@ -20,5 +20,6 @@ import type { PROTO } from '../constants'; | ||
deviceId: string | null; | ||
deviceType: IDeviceType; | ||
deviceType: IDeviceType | null; | ||
path: string; | ||
label: string; | ||
bleName: string | null; | ||
name: string; | ||
@@ -77,3 +78,3 @@ error?: typeof undefined; | ||
export type IDeviceType = 'classic' | 'classic1s' | 'mini' | 'touch' | 'pro'; | ||
export type IDeviceType = 'unknown' | 'classic' | 'classic1s' | 'mini' | 'touch' | 'pro'; | ||
@@ -99,2 +100,3 @@ /** | ||
pro: ['model_touch'], | ||
unknown: [], | ||
}; | ||
@@ -108,4 +110,9 @@ | ||
export type IVersionRange = { | ||
min: string; | ||
max?: string; | ||
}; | ||
export type DeviceFirmwareRange = { | ||
[deviceType in IDeviceType | IDeviceModel]?: { min: string; max?: string }; | ||
[deviceType in IDeviceType | IDeviceModel]?: IVersionRange; | ||
}; | ||
@@ -112,0 +119,0 @@ |
@@ -65,7 +65,8 @@ import type { IDeviceType } from './device'; | ||
type IKnownDevice = Exclude<IDeviceType, 'unknown'>; | ||
export type DeviceTypeMap = { | ||
[k in IDeviceType]: { | ||
[k in IKnownDevice]: { | ||
firmware: IFirmwareReleaseInfo[]; | ||
'firmware-v2'?: IFirmwareReleaseInfo[]; | ||
'firmware-v4'?: IFirmwareReleaseInfo[]; | ||
'firmware-v5'?: IFirmwareReleaseInfo[]; | ||
ble: IBLEFirmwareReleaseInfo[]; | ||
@@ -72,0 +73,0 @@ }; |
@@ -5,9 +5,3 @@ import semver from 'semver'; | ||
import { DeviceCommands } from '../device/DeviceCommands'; | ||
import type { | ||
Features, | ||
IDeviceModel, | ||
IDeviceType, | ||
IVersionArray, | ||
SupportFeatureType, | ||
} from '../types'; | ||
import type { Features, SupportFeatureType } from '../types'; | ||
import { DeviceModelToTypes, DeviceTypeToModels } from '../types'; | ||
@@ -17,139 +11,5 @@ import DataManager, { FirmwareField, MessageVersion } from '../data-manager/DataManager'; | ||
import { Device } from '../device/Device'; | ||
import { getDeviceType } from './deviceInfoUtils'; | ||
import { getDeviceFirmwareVersion } from './deviceVersionUtils'; | ||
export const getDeviceModel = (features?: Features): IDeviceModel => { | ||
if (!features || typeof features !== 'object') { | ||
return 'model_mini'; | ||
} | ||
if (!features.model) { | ||
return 'model_mini'; | ||
} | ||
if (features.model === '1') { | ||
return 'model_mini'; | ||
} | ||
// model === 'T' | ||
return 'model_touch'; | ||
}; | ||
export const getDeviceType = (features?: Features): IDeviceType => { | ||
if (!features || typeof features !== 'object') { | ||
return 'classic'; | ||
} | ||
// classic1s 3.5.0 pro 4.6.0 | ||
switch (features.onekey_device_type) { | ||
case 'CLASSIC': | ||
return 'classic'; | ||
case 'CLASSIC1S': | ||
return 'classic1s'; | ||
case 'MINI': | ||
return 'mini'; | ||
case 'TOUCH': | ||
return 'touch'; | ||
case 'PRO': | ||
return 'pro'; | ||
default: | ||
// other | ||
} | ||
// low version hardware | ||
if (!features.serial_no) return 'classic'; | ||
const serialNo = features.serial_no; | ||
const miniFlag = serialNo.slice(0, 2); | ||
if (miniFlag.toLowerCase() === 'mi') return 'mini'; | ||
if (miniFlag.toLowerCase() === 'tc') return 'touch'; | ||
return 'classic'; | ||
}; | ||
export const getDeviceTypeOnBootloader = (features?: Features): IDeviceType => | ||
getDeviceType(features); | ||
export const getDeviceTypeByBleName = (name?: string): IDeviceType | null => { | ||
if (!name) return 'classic'; | ||
if (name.startsWith('MI')) return 'mini'; | ||
if (name.startsWith('T')) return 'touch'; | ||
return 'classic'; | ||
}; | ||
// @deprecated | ||
export const getDeviceTypeByDeviceId = (deviceId?: string): IDeviceType => { | ||
if (!deviceId) { | ||
return 'classic'; | ||
} | ||
const miniFlag = deviceId.slice(0, 2); | ||
if (miniFlag.toLowerCase() === 'mi') return 'mini'; | ||
return 'classic'; | ||
}; | ||
export const getDeviceUUID = (features: Features) => { | ||
const deviceType = getDeviceType(features); | ||
if (features.onekey_serial_no) return features.onekey_serial_no; | ||
if (deviceType === 'classic') { | ||
return features.onekey_serial ?? ''; | ||
} | ||
return features.serial_no ?? ''; | ||
}; | ||
export const getDeviceLabel = (features: Features) => { | ||
const deviceType = getDeviceType(features); | ||
// '' empty string or string | ||
if (typeof features.label === 'string') { | ||
return features.label; | ||
} | ||
return `My OneKey ${deviceType.charAt(0).toUpperCase() + deviceType.slice(1)}`; | ||
}; | ||
/** | ||
* Get Connected Device version by features | ||
*/ | ||
export const getDeviceFirmwareVersion = (features: Features | undefined): IVersionArray => { | ||
if (!features) return [0, 0, 0]; | ||
if (semver.valid(features.onekey_firmware_version)) { | ||
return features.onekey_firmware_version?.split('.') as unknown as IVersionArray; | ||
} | ||
if (semver.valid(features.onekey_version)) { | ||
return features.onekey_version?.split('.') as unknown as IVersionArray; | ||
} | ||
return [ | ||
features.major_version ?? '0', | ||
features.minor_version ?? '0', | ||
features.patch_version ?? '0', | ||
]; | ||
}; | ||
/** | ||
* Get Connected Device bluetooth firmware version by features | ||
*/ | ||
export const getDeviceBLEFirmwareVersion = (features: Features): IVersionArray | null => { | ||
if (!features.ble_ver) { | ||
return null; | ||
} | ||
if (!semver.valid(features.ble_ver)) { | ||
return null; | ||
} | ||
return features.ble_ver.split('.') as unknown as IVersionArray; | ||
}; | ||
export const getDeviceBootloaderVersion = (features: Features): IVersionArray => { | ||
// classic1s 3.5.0 pro 4.6.0 | ||
if (semver.valid(features.onekey_boot_version)) { | ||
return features.onekey_boot_version?.split('.') as unknown as IVersionArray; | ||
} | ||
if (!features.bootloader_version) { | ||
if (features.bootloader_mode) { | ||
return [features.major_version, features.minor_version, features.patch_version]; | ||
} | ||
return [0, 0, 0]; | ||
} | ||
if (semver.valid(features.bootloader_version)) { | ||
return features.bootloader_version?.split('.') as unknown as IVersionArray; | ||
} | ||
return [0, 0, 0]; | ||
}; | ||
export const getSupportMessageVersion = ( | ||
@@ -294,3 +154,3 @@ features: Features | undefined | ||
if (DeviceModelToTypes.model_mini.includes(deviceType)) { | ||
return 'firmware-v4'; | ||
return 'firmware-v5'; | ||
} | ||
@@ -301,3 +161,3 @@ | ||
if (semver.eq(targetVersion, '4.0.0')) return 'firmware-v2'; | ||
if (semver.gt(targetVersion, '4.0.0')) return 'firmware-v4'; | ||
if (semver.gt(targetVersion, '4.0.0')) return 'firmware-v5'; | ||
} | ||
@@ -307,5 +167,8 @@ | ||
return 'firmware-v4'; | ||
return 'firmware-v5'; | ||
} | ||
if (deviceType === 'pro') { | ||
return 'firmware-v5'; | ||
} | ||
return 'firmware'; | ||
}; |
export * from './assets'; | ||
export * from './versionUtils'; | ||
export * from './patch'; | ||
// Device utils | ||
export { | ||
getDeviceTypeByBleName, | ||
getDeviceType, | ||
getDeviceTypeByBleName, | ||
getDeviceTypeByDeviceId, | ||
getDeviceBleName, | ||
getDeviceUUID, | ||
getDeviceLabel, | ||
getFirmwareUpdateField, | ||
getMethodVersionRange, | ||
} from './deviceInfoUtils'; | ||
export { | ||
getDeviceBoardloaderVersion, | ||
getDeviceBootloaderVersion, | ||
getDeviceFirmwareVersion, | ||
getDeviceBootloaderVersion, | ||
supportInputPinOnSoftware, | ||
} from './deviceFeaturesUtils'; | ||
export { getHDPath, getScriptType, getOutputScriptType } from '../api/helpers/pathUtils'; | ||
getDeviceBLEFirmwareVersion, | ||
} from './deviceVersionUtils'; | ||
export { getFirmwareUpdateField, supportInputPinOnSoftware } from './deviceFeaturesUtils'; | ||
export { | ||
@@ -22,4 +25,9 @@ checkNeedUpdateBootForTouch, | ||
// Helpers utils | ||
export { getLogger, enableLog, LoggerNames, getLog, setLoggerPostMessage } from './logger'; | ||
export { getHDPath, getScriptType, getOutputScriptType } from '../api/helpers/pathUtils'; | ||
export const isBleConnect = (env: string) => env === 'react-native' || env === 'lowlevel'; | ||
export { getHomeScreenHex } from './homescreen'; | ||
@@ -31,3 +39,1 @@ | ||
}); | ||
export const isBleConnect = (env: string) => env === 'react-native' || env === 'lowlevel'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
2652703
900
80671