@onekeyfe/hd-core 1.1.28 → 1.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/evmLedgerLegacySafety.test.ts +15 -4
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/logBlockEvent.test.ts +37 -0
- package/__tests__/protocol-v2.test.ts +2908 -0
- package/dist/api/BaseMethod.d.ts +1 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/DirList.d.ts +10 -0
- package/dist/api/DirList.d.ts.map +1 -0
- package/dist/api/DirMake.d.ts +9 -0
- package/dist/api/DirMake.d.ts.map +1 -0
- package/dist/api/DirRemove.d.ts +9 -0
- package/dist/api/DirRemove.d.ts.map +1 -0
- package/dist/api/FileDelete.d.ts +9 -0
- package/dist/api/FileDelete.d.ts.map +1 -0
- package/dist/api/FileRead.d.ts +19 -0
- package/dist/api/FileRead.d.ts.map +1 -0
- package/dist/api/FileWrite.d.ts +24 -0
- package/dist/api/FileWrite.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +35 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
- package/dist/api/GetDeviceInfo.d.ts +9 -0
- package/dist/api/GetDeviceInfo.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +6 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/PathInfo.d.ts +10 -0
- package/dist/api/PathInfo.d.ts.map +1 -0
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +2 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -8
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +1 -11
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +1 -15
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getAddress.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getPublicKey.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signMessage.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/verifyMessage.d.ts.map +1 -1
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts +3 -0
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +7 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- package/dist/api/index.d.ts +32 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +4 -0
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +2 -8
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +9 -12
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +3 -0
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/networks.d.ts +3 -0
- package/dist/api/polkadot/networks.d.ts.map +1 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DevReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +29 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +7 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +6 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +13 -0
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +6 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +1 -0
- package/dist/api/protocol-v2/Ping.d.ts +8 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +33 -0
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
- package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +1 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +3 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +3 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +6 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +3 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +3 -0
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +3 -0
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +3 -0
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +5 -2
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +3 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +5 -0
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +3 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +3 -0
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +4 -0
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +4 -0
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +7 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +5 -4
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +33 -11
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +9 -9
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceProfile.d.ts +21 -0
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -0
- package/dist/deviceProfile/index.d.ts +3 -0
- package/dist/deviceProfile/index.d.ts.map +1 -0
- package/dist/events/logBlockEvent.d.ts +1 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +8 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +717 -302
- package/dist/index.js +17654 -1271
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +93 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +13 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +4 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +27 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +85 -0
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -0
- package/dist/types/api/getPassphraseState.d.ts +10 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +37 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +103 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -0
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.d.ts.map +1 -1
- package/dist/types/device.d.ts +91 -5
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +2 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +2 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +6 -8
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +1 -0
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/findDefectiveBatchDevice.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +26 -22
- package/src/api/DirList.ts +31 -0
- package/src/api/DirMake.ts +23 -0
- package/src/api/DirRemove.ts +23 -0
- package/src/api/FileDelete.ts +23 -0
- package/src/api/FileRead.ts +167 -0
- package/src/api/FileWrite.ts +216 -0
- package/src/api/FirmwareUpdate.ts +13 -5
- package/src/api/FirmwareUpdateV2.ts +22 -19
- package/src/api/FirmwareUpdateV3.ts +19 -5
- package/src/api/FirmwareUpdateV4.ts +820 -0
- package/src/api/GetDeviceInfo.ts +145 -0
- package/src/api/GetFeatures.ts +5 -2
- package/src/api/GetOnekeyFeatures.ts +84 -3
- package/src/api/GetPassphraseState.ts +16 -10
- package/src/api/PathInfo.ts +39 -0
- package/src/api/PromptWebDeviceAccess.ts +11 -1
- package/src/api/SearchDevices.ts +7 -2
- package/src/api/alephium/AlephiumGetAddress.ts +6 -2
- package/src/api/alephium/AlephiumSignMessage.ts +6 -1
- package/src/api/alephium/AlephiumSignTransaction.ts +15 -4
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +21 -13
- package/src/api/aptos/AptosGetAddress.ts +2 -3
- package/src/api/benfen/BenfenGetAddress.ts +11 -7
- package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
- package/src/api/benfen/BenfenSignMessage.ts +6 -1
- package/src/api/benfen/BenfenSignTransaction.ts +6 -1
- package/src/api/btc/BTCGetPublicKey.ts +3 -2
- package/src/api/btc/BTCSignPsbt.ts +1 -2
- package/src/api/btc/helpers/versionLimit.ts +7 -1
- package/src/api/cardano/CardanoSignTransaction.ts +2 -4
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceFullyUploadResource.ts +3 -3
- package/src/api/device/DeviceLock.ts +1 -3
- package/src/api/device/DeviceRebootToBoardloader.ts +10 -1
- package/src/api/device/DeviceRebootToBootloader.ts +10 -1
- package/src/api/device/DeviceSupportFeatures.ts +2 -13
- package/src/api/device/DeviceUpdateBootloader.ts +4 -4
- package/src/api/device/DeviceUploadResource.ts +4 -5
- package/src/api/device/DeviceVerify.ts +1 -2
- package/src/api/dynex/DnxGetAddress.ts +6 -0
- package/src/api/dynex/DnxSignTransaction.ts +6 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +3 -4
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +32 -18
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/evm/latest/signTypedHash.ts +2 -4
- package/src/api/evm/legacyV1/getAddress.ts +5 -3
- package/src/api/evm/legacyV1/getPublicKey.ts +5 -3
- package/src/api/evm/legacyV1/signMessage.ts +5 -3
- package/src/api/evm/legacyV1/signTypedData.ts +9 -8
- package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
- package/src/api/evm/legacyV1/verifyMessage.ts +5 -3
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +8 -8
- package/src/api/firmware/bootloaderHelper.ts +3 -2
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/uploadFirmware.ts +8 -12
- package/src/api/helpers/batchGetPublickeys.ts +51 -6
- package/src/api/helpers/filesystemValidation.ts +51 -0
- package/src/api/index.ts +34 -0
- package/src/api/kaspa/KaspaSignTransaction.ts +4 -5
- package/src/api/lightning/LnurlAuth.ts +4 -0
- package/src/api/neo/NeoGetAddress.ts +6 -1
- package/src/api/neo/NeoSignTransaction.ts +6 -1
- package/src/api/nervos/NervosGetAddress.ts +6 -2
- package/src/api/nervos/NervosSignTransaction.ts +14 -4
- package/src/api/nexa/NexaGetAddress.ts +6 -2
- package/src/api/nexa/NexaSignTransaction.ts +11 -12
- package/src/api/polkadot/networks.ts +9 -0
- package/src/api/protocol-v2/DevReboot.ts +24 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +63 -0
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +118 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +20 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +16 -0
- package/src/api/protocol-v2/DeviceReboot.ts +24 -0
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +29 -0
- package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +20 -0
- package/src/api/protocol-v2/FilesystemDiskControl.ts +50 -0
- package/src/api/protocol-v2/FilesystemFixPermission.ts +16 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +16 -0
- package/src/api/protocol-v2/GetProtoVersion.ts +16 -0
- package/src/api/protocol-v2/Ping.ts +18 -0
- package/src/api/protocol-v2/helpers.ts +182 -0
- package/src/api/scdo/ScdoGetAddress.ts +6 -2
- package/src/api/scdo/ScdoSignMessage.ts +6 -1
- package/src/api/scdo/ScdoSignTransaction.ts +6 -2
- package/src/api/solana/SolGetAddress.ts +4 -0
- package/src/api/solana/SolSignMessage.ts +3 -0
- package/src/api/solana/SolSignOffchainMessage.ts +3 -0
- package/src/api/solana/SolSignTransaction.ts +6 -0
- package/src/api/stellar/StellarGetAddress.ts +10 -1
- package/src/api/stellar/StellarSignTransaction.ts +14 -1
- package/src/api/sui/SuiGetAddress.ts +5 -3
- package/src/api/sui/SuiGetPublicKey.ts +3 -0
- package/src/api/sui/SuiSignMessage.ts +3 -0
- package/src/api/sui/SuiSignTransaction.ts +14 -12
- package/src/api/ton/TonGetAddress.ts +3 -0
- package/src/api/ton/TonSignData.ts +10 -3
- package/src/api/ton/TonSignMessage.ts +6 -5
- package/src/api/ton/TonSignProof.ts +3 -0
- package/src/api/tron/TronSignMessage.ts +5 -1
- package/src/api/tron/TronSignTransaction.ts +4 -0
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/constants/index.ts +10 -1
- package/src/core/index.ts +91 -61
- package/src/data/messages/messages-protocol-v2.json +13375 -0
- package/src/data-manager/DataManager.ts +16 -11
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/data-manager/connectSettings.ts +6 -0
- package/src/device/Device.ts +398 -76
- package/src/device/DeviceCommands.ts +195 -29
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DevicePool.ts +8 -8
- package/src/deviceProfile/buildDeviceFeatures.ts +368 -0
- package/src/deviceProfile/buildDeviceProfile.ts +333 -0
- package/src/deviceProfile/index.ts +5 -0
- package/src/events/logBlockEvent.ts +23 -0
- package/src/events/ui-request.ts +8 -0
- package/src/inject.ts +52 -1
- package/src/protocols/protocol-v2/features.ts +178 -0
- package/src/protocols/protocol-v2/firmware.ts +43 -0
- package/src/protocols/protocol-v2/index.ts +16 -0
- package/src/types/api/export.ts +1 -0
- package/src/types/api/firmwareUpdate.ts +49 -0
- package/src/types/api/getDeviceInfo.ts +99 -0
- package/src/types/api/getPassphraseState.ts +13 -2
- package/src/types/api/index.ts +88 -1
- package/src/types/api/protocolV2.ts +200 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +102 -5
- package/src/types/params.ts +7 -0
- package/src/types/settings.ts +6 -1
- package/src/utils/capabilitieUtils.ts +1 -2
- package/src/utils/deviceFeaturesUtils.ts +75 -81
- package/src/utils/deviceInfoUtils.ts +23 -34
- package/src/utils/deviceVersionUtils.ts +7 -25
- package/src/utils/findDefectiveBatchDevice.ts +6 -6
- package/src/utils/index.ts +1 -0
|
@@ -5,6 +5,7 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
5
5
|
import { stripHexPrefix } from '../helpers/hexUtils';
|
|
6
6
|
|
|
7
7
|
import type { BenfenSignMessage as HardwareBenfenSignMessage } from '@onekeyfe/hd-transport';
|
|
8
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
8
9
|
|
|
9
10
|
export default class BenfenSignMessage extends BaseMethod<HardwareBenfenSignMessage> {
|
|
10
11
|
init() {
|
|
@@ -26,8 +27,12 @@ export default class BenfenSignMessage extends BaseMethod<HardwareBenfenSignMess
|
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
getVersionRange() {
|
|
30
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
30
31
|
return {
|
|
32
|
+
pro2: {
|
|
33
|
+
min: '0.0.0',
|
|
34
|
+
unsupported: true,
|
|
35
|
+
},
|
|
31
36
|
pro: {
|
|
32
37
|
min: '4.12.0',
|
|
33
38
|
},
|
|
@@ -8,6 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
8
8
|
|
|
9
9
|
import type { BenfenSignTx, BenfenSignedTx, MessageType, TypedCall } from '@onekeyfe/hd-transport';
|
|
10
10
|
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
11
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
11
12
|
|
|
12
13
|
export default class BenfenSignTransaction extends BaseMethod<BenfenSignTx> {
|
|
13
14
|
init() {
|
|
@@ -33,8 +34,12 @@ export default class BenfenSignTransaction extends BaseMethod<BenfenSignTx> {
|
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
getVersionRange() {
|
|
37
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
37
38
|
return {
|
|
39
|
+
pro2: {
|
|
40
|
+
min: '0.0.0',
|
|
41
|
+
unsupported: true,
|
|
42
|
+
},
|
|
38
43
|
pro: {
|
|
39
44
|
min: '4.12.0',
|
|
40
45
|
},
|
|
@@ -78,7 +78,8 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
for (const param of this.params) {
|
|
81
|
-
|
|
81
|
+
// init() 必然设置 coin_name;生成类型里该字段为 optional,这里兜底空串
|
|
82
|
+
const versionBytes = getVersionBytes(param.coin_name ?? '', param.script_type);
|
|
82
83
|
if (!versionBytes) {
|
|
83
84
|
throw new Error(
|
|
84
85
|
`Invalid coinName, not support generate xpub for scriptType: ${param.script_type}`
|
|
@@ -101,7 +102,7 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
|
|
|
101
102
|
|
|
102
103
|
const path = serializedPath(param.address_n);
|
|
103
104
|
|
|
104
|
-
const xpub = createExtendedPublicKey(node, param.coin_name, param.script_type);
|
|
105
|
+
const xpub = createExtendedPublicKey(node, param.coin_name ?? '', param.script_type);
|
|
105
106
|
|
|
106
107
|
const rootFingerprint = res.root_fingerprint;
|
|
107
108
|
|
|
@@ -5,7 +5,6 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
5
5
|
import { validateParams } from '../helpers/paramsValidator';
|
|
6
6
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
7
7
|
import { getCoinInfo } from './helpers/btcParamsUtils';
|
|
8
|
-
import { getDeviceType } from '../../utils';
|
|
9
8
|
|
|
10
9
|
import type { SignPsbt } from '@onekeyfe/hd-transport';
|
|
11
10
|
|
|
@@ -50,7 +49,7 @@ export default class BTCSignPsbt extends BaseMethod<SignPsbt> {
|
|
|
50
49
|
} catch (error) {
|
|
51
50
|
const { message } = error;
|
|
52
51
|
|
|
53
|
-
const deviceType =
|
|
52
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
54
53
|
if (
|
|
55
54
|
message.includes('PSBT parse failed') &&
|
|
56
55
|
(deviceType === EDeviceType.Classic1s || deviceType === EDeviceType.ClassicPure)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { DeviceFirmwareRange } from '../../../types';
|
|
2
|
+
|
|
1
3
|
function isCoinNameInList(coinName: string, coinNames: (string | undefined)[]) {
|
|
2
4
|
for (let i = 0; i < coinNames.length; i++) {
|
|
3
5
|
const coin_name = coinNames[i];
|
|
@@ -8,9 +10,13 @@ function isCoinNameInList(coinName: string, coinNames: (string | undefined)[]) {
|
|
|
8
10
|
return false;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export function getBitcoinForkVersionRange(params: (string | undefined)[]) {
|
|
13
|
+
export function getBitcoinForkVersionRange(params: (string | undefined)[]): DeviceFirmwareRange {
|
|
12
14
|
if (isCoinNameInList('Neurai', params)) {
|
|
13
15
|
return {
|
|
16
|
+
pro2: {
|
|
17
|
+
min: '0.0.0',
|
|
18
|
+
unsupported: true,
|
|
19
|
+
},
|
|
14
20
|
model_mini: {
|
|
15
21
|
min: '3.7.0',
|
|
16
22
|
},
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
} from './helper/auxiliaryData';
|
|
20
20
|
import { gatherWitnessPaths } from './helper/witnesses';
|
|
21
21
|
import { validatePath } from '../helpers/pathUtils';
|
|
22
|
-
import { getDeviceFirmwareVersion, getMethodVersionRange } from '../../utils';
|
|
23
22
|
|
|
24
23
|
import type { DeviceFirmwareRange } from '../../types';
|
|
25
24
|
import type { CollateralInputWithPath, Path } from './helper/cardanoInputs';
|
|
@@ -240,10 +239,9 @@ export default class CardanoSignTransaction extends BaseMethod<any> {
|
|
|
240
239
|
return;
|
|
241
240
|
}
|
|
242
241
|
|
|
243
|
-
const firmwareVersion =
|
|
242
|
+
const firmwareVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
244
243
|
|
|
245
|
-
const versionRange =
|
|
246
|
-
this.device.features,
|
|
244
|
+
const versionRange = this.device.getCurrentMethodVersionRange(
|
|
247
245
|
type => this.supportConwayVersionRange()[type]
|
|
248
246
|
);
|
|
249
247
|
|
|
@@ -35,7 +35,7 @@ export default class ConfluxSignTransaction extends BaseMethod {
|
|
|
35
35
|
|
|
36
36
|
// check if transaction is valid
|
|
37
37
|
const schema: SchemaParam[] = [
|
|
38
|
-
{ name: 'to', type: '
|
|
38
|
+
{ name: 'to', type: 'string', required: true },
|
|
39
39
|
{ name: 'value', type: 'hexString', required: true },
|
|
40
40
|
{ name: 'gasLimit', type: 'hexString', required: true },
|
|
41
41
|
{ name: 'gasPrice', type: 'hexString', required: true },
|
|
@@ -48,7 +48,10 @@ export default class ConfluxSignTransaction extends BaseMethod {
|
|
|
48
48
|
|
|
49
49
|
validateParams(tx, schema);
|
|
50
50
|
|
|
51
|
-
this.formattedTx =
|
|
51
|
+
this.formattedTx = {
|
|
52
|
+
...formatAnyHex(tx),
|
|
53
|
+
to: tx.to,
|
|
54
|
+
};
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
processTxRequest = async (request: ConfluxTxRequest, data: string): Promise<ConfluxSignedTx> => {
|
|
@@ -5,7 +5,7 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
5
5
|
import { BaseMethod } from '../BaseMethod';
|
|
6
6
|
import { getSysResourceBinary } from '../firmware/getBinary';
|
|
7
7
|
import { updateResources } from '../firmware/uploadFirmware';
|
|
8
|
-
import { getDeviceFirmwareVersion,
|
|
8
|
+
import { getDeviceFirmwareVersion, getFirmwareType } from '../../utils';
|
|
9
9
|
import { createUiMessage } from '../../events/ui-request';
|
|
10
10
|
import { DataManager } from '../../data-manager';
|
|
11
11
|
|
|
@@ -36,7 +36,7 @@ export default class DeviceFullyUploadResource extends BaseMethod {
|
|
|
36
36
|
isSupportResourceUpdate(features: Features, updateType: string) {
|
|
37
37
|
if (updateType !== 'firmware') return false;
|
|
38
38
|
|
|
39
|
-
const deviceType =
|
|
39
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
40
40
|
const isTouchMode = deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro;
|
|
41
41
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
42
42
|
|
|
@@ -52,7 +52,7 @@ export default class DeviceFullyUploadResource extends BaseMethod {
|
|
|
52
52
|
const deviceFirmwareType = getFirmwareType(features);
|
|
53
53
|
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
54
54
|
|
|
55
|
-
if (!
|
|
55
|
+
if (!device.isBootloader() && features) {
|
|
56
56
|
// check & upgrade firmware resource
|
|
57
57
|
if (features) {
|
|
58
58
|
let { binary } = this.payload;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DevRebootType } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
1
3
|
import { BaseMethod } from '../BaseMethod';
|
|
2
4
|
|
|
3
5
|
import type { RebootToBoardloaderParams } from '../../types/api/deviceRebootToBoardloader';
|
|
@@ -21,10 +23,17 @@ export default class DeviceRebootToBoardloader extends BaseMethod<RebootToBoardl
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
async run() {
|
|
26
|
+
// Protocol V2 submodule firmware uses DevReboot with reboot_type enum.
|
|
27
|
+
if (this.device.isProtocolV2()) {
|
|
28
|
+
const res = await this.device.commands.typedCall('DevReboot', 'Success', {
|
|
29
|
+
reboot_type: DevRebootType.Boardloader,
|
|
30
|
+
});
|
|
31
|
+
return Promise.resolve(res.message);
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
// On Touch devices, messsage code 904 is RebootToBoardloader
|
|
25
35
|
// so BininOutMessageSE message code 904 is used here
|
|
26
36
|
const res = await this.device.commands.typedCall('BixinOutMessageSE', 'Success');
|
|
27
|
-
|
|
28
37
|
return Promise.resolve(res.message);
|
|
29
38
|
}
|
|
30
39
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DevRebootType } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
1
3
|
import { BaseMethod } from '../BaseMethod';
|
|
2
4
|
|
|
3
5
|
import type { RebootToBootloader } from '@onekeyfe/hd-transport';
|
|
@@ -21,8 +23,15 @@ export default class DeviceRebootToBootloader extends BaseMethod<RebootToBootloa
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
async run() {
|
|
24
|
-
|
|
26
|
+
// Protocol V2 submodule firmware uses DevReboot with reboot_type enum.
|
|
27
|
+
if (this.device.isProtocolV2()) {
|
|
28
|
+
const res = await this.device.commands.typedCall('DevReboot', 'Success', {
|
|
29
|
+
reboot_type: DevRebootType.Bootloader,
|
|
30
|
+
});
|
|
31
|
+
return Promise.resolve(res.message);
|
|
32
|
+
}
|
|
25
33
|
|
|
34
|
+
const res = await this.device.commands.typedCall('RebootToBootloader', 'Success');
|
|
26
35
|
return Promise.resolve(res.message);
|
|
27
36
|
}
|
|
28
37
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
supportInputPinOnSoftware,
|
|
5
|
-
supportModifyHomescreen,
|
|
6
|
-
} from '../../utils/deviceFeaturesUtils';
|
|
7
1
|
import { BaseMethod } from '../BaseMethod';
|
|
8
2
|
|
|
9
3
|
export default class DeviceSupportFeatures extends BaseMethod {
|
|
@@ -13,13 +7,8 @@ export default class DeviceSupportFeatures extends BaseMethod {
|
|
|
13
7
|
}
|
|
14
8
|
|
|
15
9
|
run() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Device not initialized')
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
|
|
22
|
-
const modifyHomescreen = supportModifyHomescreen(this.device.features);
|
|
10
|
+
const inputPinOnSoftware = this.device.supportInputPinOnSoftware();
|
|
11
|
+
const modifyHomescreen = this.device.supportModifyHomescreen();
|
|
23
12
|
return Promise.resolve({
|
|
24
13
|
inputPinOnSoftware,
|
|
25
14
|
modifyHomescreen,
|
|
@@ -9,7 +9,7 @@ import { updateBootloader } from '../firmware/uploadFirmware';
|
|
|
9
9
|
import { DeviceModelToTypes } from '../../types';
|
|
10
10
|
import { DataManager } from '../../data-manager';
|
|
11
11
|
import { checkBootloaderLength } from '../firmware/updateBootloader';
|
|
12
|
-
import {
|
|
12
|
+
import { getFirmwareType } from '../../utils';
|
|
13
13
|
|
|
14
14
|
import type { DeviceUpdateBootloaderParams } from '../../types/api/deviceUpdateBootloader';
|
|
15
15
|
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
@@ -74,13 +74,13 @@ export default class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod<any
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Check if device is in bootloader mode
|
|
77
|
-
if (features &&
|
|
77
|
+
if (features && device.isBootloader()) {
|
|
78
78
|
// Use emmcFileWrite + reboot logic for bootloader mode
|
|
79
79
|
this.postTipMessage(FirmwareUpdateTipMessage.UpdateBootloader);
|
|
80
80
|
return this.updateBootloaderWithEmmcFileWrite(device, binary);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if (features && !
|
|
83
|
+
if (features && !device.isBootloader()) {
|
|
84
84
|
// Use original updateBootloader logic for normal mode
|
|
85
85
|
await updateBootloader(
|
|
86
86
|
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
@@ -98,7 +98,7 @@ export default class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod<any
|
|
|
98
98
|
|
|
99
99
|
const payload = this.payload as DeviceUpdateBootloaderParams;
|
|
100
100
|
|
|
101
|
-
const deviceType =
|
|
101
|
+
const deviceType = device.getCurrentDeviceType();
|
|
102
102
|
const deviceFirmwareType = getFirmwareType(features);
|
|
103
103
|
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
104
104
|
|
|
@@ -8,7 +8,6 @@ import { DeviceModelToTypes } from '../../types';
|
|
|
8
8
|
import { BaseMethod } from '../BaseMethod';
|
|
9
9
|
import { validateParams } from '../helpers/paramsValidator';
|
|
10
10
|
import { hexToBytes } from '../helpers/hexUtils';
|
|
11
|
-
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
|
|
12
11
|
import { PROTO } from '../../constants';
|
|
13
12
|
|
|
14
13
|
import type { DeviceUploadResourceParams, DeviceUploadResourceResponse } from '../../types';
|
|
@@ -37,8 +36,8 @@ export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
checkUploadNFTSupport() {
|
|
40
|
-
const deviceType =
|
|
41
|
-
const currentVersion =
|
|
39
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
40
|
+
const currentVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
42
41
|
if (!DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
43
42
|
throw ERRORS.TypedError(HardwareErrorCode.CallMethodError, 'Device Not Support Upload NFT');
|
|
44
43
|
}
|
|
@@ -138,8 +137,8 @@ export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
|
|
|
138
137
|
};
|
|
139
138
|
response.applyScreen = true;
|
|
140
139
|
|
|
141
|
-
const firmwareVersion =
|
|
142
|
-
const deviceType =
|
|
140
|
+
const firmwareVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
141
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
143
142
|
if (deviceType === EDeviceType.Pro && semver.gte(firmwareVersion, '4.17.0')) {
|
|
144
143
|
response.applyScreen = false;
|
|
145
144
|
}
|
|
@@ -5,7 +5,6 @@ import { bytesToHex } from '@noble/hashes/utils';
|
|
|
5
5
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
6
6
|
import { BaseMethod } from '../BaseMethod';
|
|
7
7
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
8
|
-
import { getDeviceType } from '../../utils';
|
|
9
8
|
import { DeviceModelToTypes } from '../../types';
|
|
10
9
|
|
|
11
10
|
import type { BixinVerifyDeviceRequest } from '@onekeyfe/hd-transport';
|
|
@@ -26,7 +25,7 @@ export default class DeviceVerify extends BaseMethod<BixinVerifyDeviceRequest> {
|
|
|
26
25
|
|
|
27
26
|
async run() {
|
|
28
27
|
// For Classic、Mini device we use EthereumSignTypedData
|
|
29
|
-
const deviceType =
|
|
28
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
30
29
|
let response: DeviceVerifySignature | undefined;
|
|
31
30
|
|
|
32
31
|
if (DeviceModelToTypes.model_classic.includes(deviceType)) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createDeviceNotSupportMethodError } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
2
4
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
5
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -47,6 +49,10 @@ export default class DnxGetAddress extends BaseMethod<HardwareDnxGetAddress[]> {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
async run() {
|
|
52
|
+
if (this.device.isProtocolV2()) {
|
|
53
|
+
throw createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
const responses: DnxAddress[] = [];
|
|
51
57
|
|
|
52
58
|
for (let i = 0; i < this.params.length; i++) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createDeviceNotSupportMethodError } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
2
4
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
5
|
import { BaseMethod } from '../BaseMethod';
|
|
@@ -116,6 +118,10 @@ export default class DnxSignTransaction extends BaseMethod<DnxSignTx> {
|
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
async run() {
|
|
121
|
+
if (this.device.isProtocolV2()) {
|
|
122
|
+
throw createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
120
126
|
|
|
121
127
|
const res = await this.device.commands.typedCall('DnxSignTx', 'DnxInputRequest', {
|
|
@@ -44,7 +44,7 @@ export default class EvmGetAddress extends BaseMethod<EthereumGetAddressOneKey[]
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
async getEvmAddress(param: EthereumGetAddressOneKey) {
|
|
47
|
-
if (TransportManager.
|
|
47
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
48
48
|
return getAddressLegacyV1({
|
|
49
49
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
50
50
|
param,
|
|
@@ -2,11 +2,10 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
2
2
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
|
-
import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
|
|
6
5
|
import TransportManager from '../../data-manager/TransportManager';
|
|
7
6
|
import getPublicKey from './latest/getPublicKey';
|
|
8
7
|
import getPublicKeyLegacyV1 from './legacyV1/getPublicKey';
|
|
9
|
-
import { batchGetPublickeys } from '../helpers/batchGetPublickeys';
|
|
8
|
+
import { batchGetPublickeys, supportBatchPublicKeyByDevice } from '../helpers/batchGetPublickeys';
|
|
10
9
|
|
|
11
10
|
import type { EVMGetPublicKeyParams, EVMPublicKey } from '../../types';
|
|
12
11
|
import type { EthereumGetPublicKey, EthereumGetPublicKeyOneKey } from '@onekeyfe/hd-transport';
|
|
@@ -57,7 +56,7 @@ export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKeyOneK
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
getEvmPublicKey(param: EthereumGetPublicKey) {
|
|
60
|
-
if (TransportManager.
|
|
59
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
61
60
|
return getPublicKeyLegacyV1({
|
|
62
61
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
63
62
|
param,
|
|
@@ -73,7 +72,7 @@ export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKeyOneK
|
|
|
73
72
|
async run() {
|
|
74
73
|
const responses: EVMPublicKey[] = [];
|
|
75
74
|
|
|
76
|
-
if (this.useBatch &&
|
|
75
|
+
if (this.useBatch && supportBatchPublicKeyByDevice(this.device)) {
|
|
77
76
|
try {
|
|
78
77
|
const res = await batchGetPublickeys(this.device, this.params, 'secp256k1', 60, {
|
|
79
78
|
includeNode: false,
|
|
@@ -36,7 +36,7 @@ export default class EVMSignMessage extends BaseMethod<EthereumSignMessageOneKey
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async run() {
|
|
39
|
-
if (TransportManager.
|
|
39
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
40
40
|
return signMessageLegacyV1({
|
|
41
41
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
42
42
|
params: this.params,
|
|
@@ -5,6 +5,7 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
5
5
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
6
6
|
|
|
7
7
|
import type { EthereumSignMessageEIP712 } from '@onekeyfe/hd-transport';
|
|
8
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @deprecated Use EVMSignTypedData instead.
|
|
@@ -32,8 +33,12 @@ export default class EVMSignMessageEIP712 extends BaseMethod<EthereumSignMessage
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
getVersionRange() {
|
|
36
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
36
37
|
return {
|
|
38
|
+
pro2: {
|
|
39
|
+
min: '0.0.0',
|
|
40
|
+
unsupported: true,
|
|
41
|
+
},
|
|
37
42
|
model_mini: {
|
|
38
43
|
min: '2.1.9',
|
|
39
44
|
},
|
|
@@ -44,6 +49,14 @@ export default class EVMSignMessageEIP712 extends BaseMethod<EthereumSignMessage
|
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
async run() {
|
|
52
|
+
this.checkFeatureVersionLimit(
|
|
53
|
+
() => true,
|
|
54
|
+
() => this.getVersionRange(),
|
|
55
|
+
{
|
|
56
|
+
strictCheckDeviceSupport: true,
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
47
60
|
const res = await this.device.commands.typedCall(
|
|
48
61
|
'EthereumSignMessageEIP712',
|
|
49
62
|
'EthereumMessageSignature',
|
|
@@ -122,7 +122,7 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
122
122
|
|
|
123
123
|
if (formattedTx == null) throw ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
124
124
|
|
|
125
|
-
if (TransportManager.
|
|
125
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
126
126
|
return signTransactionLegacyV1({
|
|
127
127
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
128
128
|
addressN,
|
|
@@ -9,7 +9,6 @@ import { validatePath } from '../helpers/pathUtils';
|
|
|
9
9
|
import { BaseMethod } from '../BaseMethod';
|
|
10
10
|
import { validateParams } from '../helpers/paramsValidator';
|
|
11
11
|
import { formatAnyHex, parseChainId, stripHexStartZeroes } from '../helpers/hexUtils';
|
|
12
|
-
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
|
|
13
12
|
import { existCapability } from '../../utils/capabilitieUtils';
|
|
14
13
|
import {
|
|
15
14
|
DeviceModelToTypes,
|
|
@@ -26,11 +25,20 @@ import { encodeData, getFieldType, parseArrayType } from '../helpers/typeNameUti
|
|
|
26
25
|
import type {
|
|
27
26
|
EthereumTypedDataSignature,
|
|
28
27
|
EthereumTypedDataStructAck,
|
|
28
|
+
EthereumTypedDataStructAckOneKey,
|
|
29
29
|
MessageKey,
|
|
30
30
|
MessageResponse,
|
|
31
31
|
TypedCall,
|
|
32
32
|
} from '@onekeyfe/hd-transport';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* EthereumTypedDataStructAckOneKey 与 EthereumTypedDataStructAck 的字段结构与
|
|
36
|
+
* 枚举数值完全一致(生成产物的 OneKey/Trezor 双份消息),仅枚举名义类型不同;
|
|
37
|
+
* 这里做无运行时成本的名义转换,避免在调用点散落 any。
|
|
38
|
+
*/
|
|
39
|
+
const toOneKeyStructAck = (ack: EthereumTypedDataStructAck): EthereumTypedDataStructAckOneKey =>
|
|
40
|
+
ack as unknown as EthereumTypedDataStructAckOneKey;
|
|
41
|
+
|
|
34
42
|
export type EVMSignTypedDataParams = {
|
|
35
43
|
addressN: number[];
|
|
36
44
|
metamaskV4Compat: boolean;
|
|
@@ -130,7 +138,6 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
130
138
|
if (supportTrezor) {
|
|
131
139
|
response = await typedCall(
|
|
132
140
|
'EthereumTypedDataStructAck',
|
|
133
|
-
// @ts-ignore
|
|
134
141
|
[
|
|
135
142
|
'EthereumTypedDataStructRequest',
|
|
136
143
|
'EthereumTypedDataValueRequest',
|
|
@@ -141,13 +148,12 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
141
148
|
} else {
|
|
142
149
|
response = await typedCall(
|
|
143
150
|
'EthereumTypedDataStructAckOneKey',
|
|
144
|
-
// @ts-ignore
|
|
145
151
|
[
|
|
146
152
|
'EthereumTypedDataStructRequestOneKey',
|
|
147
153
|
'EthereumTypedDataValueRequestOneKey',
|
|
148
154
|
'EthereumTypedDataSignatureOneKey',
|
|
149
155
|
],
|
|
150
|
-
dataStruckAck
|
|
156
|
+
toOneKeyStructAck(dataStruckAck)
|
|
151
157
|
);
|
|
152
158
|
}
|
|
153
159
|
}
|
|
@@ -183,7 +189,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
183
189
|
} else if (typeof memberData === 'object' && memberData !== null) {
|
|
184
190
|
const memberTypeDefinition = types[memberTypeName][index];
|
|
185
191
|
memberTypeName = memberTypeDefinition.type;
|
|
186
|
-
memberData = memberData[memberTypeDefinition.name];
|
|
192
|
+
memberData = (memberData as Record<string, unknown>)[memberTypeDefinition.name];
|
|
187
193
|
} else {
|
|
188
194
|
// TODO
|
|
189
195
|
}
|
|
@@ -220,6 +226,15 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
220
226
|
|
|
221
227
|
if (response.type === 'EthereumGnosisSafeTxRequest') {
|
|
222
228
|
const { data } = this.params;
|
|
229
|
+
const verifyingContract = data.domain?.verifyingContract;
|
|
230
|
+
// EthereumGnosisSafeTxAck.verifyingContract 在 proto 中是 required 字段,
|
|
231
|
+
// Gnosis Safe 签名缺少 verifyingContract 没有意义,这里给出明确的参数错误。
|
|
232
|
+
if (!verifyingContract) {
|
|
233
|
+
throw ERRORS.TypedError(
|
|
234
|
+
HardwareErrorCode.CallMethodInvalidParameter,
|
|
235
|
+
'EIP712Domain.verifyingContract is required for Gnosis Safe transaction'
|
|
236
|
+
);
|
|
237
|
+
}
|
|
223
238
|
const param = {
|
|
224
239
|
to: data.message.to,
|
|
225
240
|
value: formatAnyHex(new BigNumber(data.message.value).toString(16)),
|
|
@@ -232,11 +247,10 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
232
247
|
refundReceiver: data.message.refundReceiver,
|
|
233
248
|
nonce: formatAnyHex(new BigNumber(data.message.nonce).toString(16)),
|
|
234
249
|
chain_id: parseChainId(data.domain.chainId),
|
|
235
|
-
verifyingContract
|
|
250
|
+
verifyingContract,
|
|
236
251
|
};
|
|
237
252
|
response = await typedCall(
|
|
238
253
|
'EthereumGnosisSafeTxAck',
|
|
239
|
-
// @ts-ignore
|
|
240
254
|
['EthereumTypedDataSignature', 'EthereumTypedDataSignatureOneKey'],
|
|
241
255
|
param
|
|
242
256
|
);
|
|
@@ -262,8 +276,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
262
276
|
|
|
263
277
|
let supportTrezor = false;
|
|
264
278
|
let response: MessageResponse<MessageKey>;
|
|
265
|
-
switch (TransportManager.
|
|
266
|
-
case '
|
|
279
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
280
|
+
case 'v1LegacySchema':
|
|
267
281
|
supportTrezor = true;
|
|
268
282
|
response = await signTypedDataLegacyV1({
|
|
269
283
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
@@ -274,7 +288,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
274
288
|
});
|
|
275
289
|
break;
|
|
276
290
|
|
|
277
|
-
case '
|
|
291
|
+
case 'v1CurrentSchema':
|
|
278
292
|
default:
|
|
279
293
|
supportTrezor = false;
|
|
280
294
|
response = await signTypedData({
|
|
@@ -310,8 +324,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
310
324
|
}) {
|
|
311
325
|
if (!domainHash) throw ERRORS.TypedError('Runtime', 'domainHash is required');
|
|
312
326
|
|
|
313
|
-
switch (TransportManager.
|
|
314
|
-
case '
|
|
327
|
+
switch (TransportManager.getProtocolV1MessageSchema()) {
|
|
328
|
+
case 'v1LegacySchema':
|
|
315
329
|
return signTypedHashLegacyV1({
|
|
316
330
|
typedCall,
|
|
317
331
|
addressN,
|
|
@@ -321,7 +335,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
321
335
|
device: this.device,
|
|
322
336
|
});
|
|
323
337
|
|
|
324
|
-
case '
|
|
338
|
+
case 'v1CurrentSchema':
|
|
325
339
|
default:
|
|
326
340
|
return signTypedHash({
|
|
327
341
|
typedCall,
|
|
@@ -348,8 +362,8 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
348
362
|
|
|
349
363
|
let biggerLimit = 1024; // 1k
|
|
350
364
|
|
|
351
|
-
const currentVersion =
|
|
352
|
-
const currentDeviceType =
|
|
365
|
+
const currentVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
366
|
+
const currentDeviceType = this.device.getCurrentDeviceType();
|
|
353
367
|
const supportBiggerDataVersion = '4.4.0';
|
|
354
368
|
|
|
355
369
|
const supportBiggerData =
|
|
@@ -532,9 +546,9 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
532
546
|
}
|
|
533
547
|
|
|
534
548
|
supportSignTyped() {
|
|
535
|
-
const deviceType =
|
|
549
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
536
550
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
537
|
-
const currentVersion =
|
|
551
|
+
const currentVersion = this.device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
538
552
|
const supportSignTypedVersion = '2.2.0';
|
|
539
553
|
|
|
540
554
|
if (semver.lt(currentVersion, supportSignTypedVersion)) {
|
|
@@ -564,7 +578,7 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
564
578
|
// For Classic / Mini:
|
|
565
579
|
// - If parsed typed-data capability is missing, keep using blind-sign.
|
|
566
580
|
// - For Mini with parsed capability, add extra format checks before parsed signing.
|
|
567
|
-
const deviceType =
|
|
581
|
+
const deviceType = this.device.getCurrentDeviceType();
|
|
568
582
|
if (
|
|
569
583
|
DeviceModelToTypes.model_mini.includes(deviceType) &&
|
|
570
584
|
(!supportEip712OnClassic || this.hasClassicFamilyTypedDataFormatViolations(this.params.data))
|
|
@@ -31,7 +31,7 @@ export default class EVMSignMessage extends BaseMethod<EthereumVerifyMessageOneK
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async run() {
|
|
34
|
-
if (TransportManager.
|
|
34
|
+
if (TransportManager.getProtocolV1MessageSchema() === 'v1LegacySchema') {
|
|
35
35
|
return verifyMessageLegacyV1({
|
|
36
36
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
37
37
|
params: this.params,
|