@onekeyfe/hd-core 1.1.27-alpha.4 → 1.1.27-alpha.40
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__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/protocol-v2.test.ts +1661 -0
- package/dist/api/BaseMethod.d.ts +1 -7
- 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 +23 -0
- package/dist/api/FileWrite.d.ts.map +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +32 -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/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 +9 -0
- package/dist/api/PathInfo.d.ts.map +1 -0
- 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 +2 -5
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
- package/dist/api/aptos/AptosSignTransaction.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/CardanoSignMessage.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/cosmos/CosmosSignTransaction.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/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessage.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/EVMSignTransaction.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/legacyV1/signTypedData.d.ts +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
- package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +10 -2
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/helpers/deviceInfo.d.ts +15 -0
- package/dist/api/helpers/deviceInfo.d.ts.map +1 -0
- 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 +28 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
- package/dist/api/nem/NEMSignTransaction.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 +2 -9
- 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/nostr/NostrSignEvent.d.ts.map +1 -1
- package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
- 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 +7 -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 +10 -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 +49 -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 +6 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +4 -0
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +4 -0
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +8 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
- package/dist/api/starcoin/StarcoinSignTransaction.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 +2 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +2 -2
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronGetAddress.d.ts +4 -0
- package/dist/api/tron/TronGetAddress.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/api/xrp/XrpSignTransaction.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +1 -1
- package/dist/core/RequestQueue.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/device/Device.d.ts +5 -18
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -8
- 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/events/ui-request.d.ts +8 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +292 -43
- package/dist/index.js +16693 -1497
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +104 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +12 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +3 -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 +7 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +84 -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 +33 -3
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +127 -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 +6 -2
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +2 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +5 -3
- 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/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/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +7 -82
- package/src/api/DirList.ts +29 -0
- package/src/api/DirMake.ts +21 -0
- package/src/api/DirRemove.ts +21 -0
- package/src/api/FileDelete.ts +21 -0
- package/src/api/FileRead.ts +165 -0
- package/src/api/FileWrite.ts +203 -0
- package/src/api/FirmwareUpdateV3.ts +21 -4
- package/src/api/FirmwareUpdateV4.ts +810 -0
- package/src/api/GetDeviceInfo.ts +161 -0
- package/src/api/GetOnekeyFeatures.ts +75 -3
- package/src/api/GetPassphraseState.ts +16 -7
- package/src/api/PathInfo.ts +25 -0
- package/src/api/SearchDevices.ts +7 -2
- package/src/api/alephium/AlephiumGetAddress.ts +6 -2
- package/src/api/alephium/AlephiumSignMessage.ts +6 -2
- package/src/api/alephium/AlephiumSignTransaction.ts +6 -3
- package/src/api/algo/AlgoSignTransaction.ts +0 -1
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +18 -9
- package/src/api/aptos/AptosSignInMessage.ts +0 -1
- package/src/api/aptos/AptosSignMessage.ts +0 -1
- package/src/api/aptos/AptosSignTransaction.ts +0 -1
- package/src/api/benfen/BenfenGetAddress.ts +6 -2
- package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
- package/src/api/benfen/BenfenSignMessage.ts +6 -2
- package/src/api/benfen/BenfenSignTransaction.ts +6 -2
- package/src/api/btc/BTCSignMessage.ts +0 -1
- package/src/api/btc/BTCSignPsbt.ts +0 -1
- package/src/api/btc/BTCSignTransaction.ts +0 -1
- package/src/api/btc/helpers/versionLimit.ts +7 -1
- package/src/api/cardano/CardanoSignMessage.ts +0 -1
- package/src/api/cardano/CardanoSignTransaction.ts +0 -1
- package/src/api/conflux/ConfluxSignMessage.ts +0 -1
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +0 -1
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -3
- package/src/api/cosmos/CosmosSignTransaction.ts +0 -1
- package/src/api/device/DeviceRebootToBoardloader.ts +10 -1
- package/src/api/device/DeviceRebootToBootloader.ts +10 -1
- package/src/api/dynex/DnxGetAddress.ts +7 -0
- package/src/api/dynex/DnxSignTransaction.ts +7 -1
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -3
- package/src/api/evm/EVMSignMessageEIP712.ts +14 -2
- package/src/api/evm/EVMSignTransaction.ts +1 -3
- package/src/api/evm/EVMSignTypedData.ts +6 -8
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/filecoin/FilecoinSignTransaction.ts +0 -1
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +27 -4
- package/src/api/helpers/deviceInfo.ts +205 -0
- package/src/api/helpers/filesystemValidation.ts +51 -0
- package/src/api/index.ts +30 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +0 -1
- package/src/api/near/NearSignTransaction.ts +0 -1
- package/src/api/nem/NEMSignTransaction.ts +0 -1
- package/src/api/neo/NeoGetAddress.ts +6 -1
- package/src/api/neo/NeoSignTransaction.ts +6 -2
- package/src/api/nervos/NervosGetAddress.ts +6 -2
- package/src/api/nervos/NervosSignTransaction.ts +6 -3
- package/src/api/nexa/NexaGetAddress.ts +6 -2
- package/src/api/nexa/NexaSignTransaction.ts +6 -4
- package/src/api/nostr/NostrSignEvent.ts +0 -1
- package/src/api/nostr/NostrSignSchnorr.ts +0 -1
- package/src/api/polkadot/PolkadotSignTransaction.ts +0 -1
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +50 -0
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +35 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceReboot.ts +22 -0
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +27 -0
- package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +18 -0
- package/src/api/protocol-v2/FilesystemDiskControl.ts +34 -0
- package/src/api/protocol-v2/FilesystemFixPermission.ts +14 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +14 -0
- package/src/api/protocol-v2/GetProtoVersion.ts +14 -0
- package/src/api/protocol-v2/Ping.ts +16 -0
- package/src/api/protocol-v2/helpers.ts +161 -0
- package/src/api/scdo/ScdoGetAddress.ts +6 -2
- package/src/api/scdo/ScdoSignMessage.ts +6 -2
- package/src/api/scdo/ScdoSignTransaction.ts +6 -3
- package/src/api/solana/SolGetAddress.ts +9 -0
- package/src/api/solana/SolSignMessage.ts +4 -1
- package/src/api/solana/SolSignOffchainMessage.ts +4 -1
- package/src/api/solana/SolSignTransaction.ts +8 -1
- package/src/api/starcoin/StarcoinSignMessage.ts +0 -1
- package/src/api/starcoin/StarcoinSignTransaction.ts +0 -1
- package/src/api/stellar/StellarGetAddress.ts +10 -1
- package/src/api/stellar/StellarSignTransaction.ts +14 -2
- package/src/api/sui/SuiSignMessage.ts +0 -1
- package/src/api/sui/SuiSignTransaction.ts +12 -10
- package/src/api/ton/TonSignData.ts +0 -1
- package/src/api/ton/TonSignMessage.ts +0 -1
- package/src/api/ton/TonSignProof.ts +0 -1
- package/src/api/tron/TronGetAddress.ts +4 -0
- package/src/api/tron/TronSignMessage.ts +5 -2
- package/src/api/tron/TronSignTransaction.ts +4 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -2
- package/src/core/RequestQueue.ts +3 -10
- package/src/core/index.ts +62 -153
- package/src/data/messages/messages-protocol-v2.json +13128 -0
- package/src/data-manager/DataManager.ts +12 -7
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/device/Device.ts +88 -77
- package/src/device/DeviceCommands.ts +166 -26
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DevicePool.ts +1 -1
- package/src/events/ui-request.ts +8 -0
- package/src/inject.ts +46 -2
- package/src/protocols/protocol-v2/features.ts +287 -0
- package/src/protocols/protocol-v2/firmware.ts +26 -0
- package/src/protocols/protocol-v2/index.ts +2 -0
- package/src/types/api/export.ts +1 -0
- package/src/types/api/firmwareUpdate.ts +12 -0
- package/src/types/api/getDeviceInfo.ts +97 -0
- package/src/types/api/getPassphraseState.ts +13 -2
- package/src/types/api/index.ts +80 -3
- package/src/types/api/protocolV2.ts +226 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +33 -2
- package/src/types/params.ts +4 -2
- package/src/types/settings.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +62 -21
- package/src/utils/deviceInfoUtils.ts +15 -8
- package/src/utils/index.ts +1 -0
- package/__tests__/DeviceCommands.test.ts +0 -99
- package/__tests__/evmLedgerLegacySafety.test.ts +0 -261
- package/__tests__/preInitialize.test.ts +0 -22
- package/dist/api/device/PreInitialize.d.ts +0 -6
- package/dist/api/device/PreInitialize.d.ts.map +0 -1
- package/dist/core/PollingStateManager.d.ts +0 -8
- package/dist/core/PollingStateManager.d.ts.map +0 -1
- package/dist/types/api/preInitialize.d.ts +0 -3
- package/dist/types/api/preInitialize.d.ts.map +0 -1
- package/src/api/device/PreInitialize.ts +0 -41
- package/src/core/PollingStateManager.ts +0 -47
- package/src/types/api/preInitialize.ts +0 -3
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { DeviceRebootType } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import { invalidParameter, validateNonEmptyString } from '../helpers/filesystemValidation';
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
DeviceFirmwareTarget,
|
|
7
|
+
DeviceFirmwareTargetType,
|
|
8
|
+
DeviceInfoTargets,
|
|
9
|
+
DeviceInfoTypes,
|
|
10
|
+
TransportCallOptions,
|
|
11
|
+
} from '@onekeyfe/hd-transport';
|
|
12
|
+
|
|
13
|
+
export type RebootTypeInput = DeviceRebootType | keyof typeof DeviceRebootType | string | number;
|
|
14
|
+
|
|
15
|
+
export type DeviceRebootParams = {
|
|
16
|
+
rebootType?: RebootTypeInput;
|
|
17
|
+
reboot_type?: RebootTypeInput;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type DeviceGetDeviceInfoParams = {
|
|
21
|
+
targets?: DeviceInfoTargets;
|
|
22
|
+
types?: DeviceInfoTypes;
|
|
23
|
+
targetHw?: boolean;
|
|
24
|
+
targetFw?: boolean;
|
|
25
|
+
targetBt?: boolean;
|
|
26
|
+
targetSe1?: boolean;
|
|
27
|
+
targetSe2?: boolean;
|
|
28
|
+
targetSe3?: boolean;
|
|
29
|
+
targetSe4?: boolean;
|
|
30
|
+
targetStatus?: boolean;
|
|
31
|
+
includeVersion?: boolean;
|
|
32
|
+
includeBuildId?: boolean;
|
|
33
|
+
includeHash?: boolean;
|
|
34
|
+
includeSpecific?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type DeviceFirmwareTargetInput =
|
|
38
|
+
| DeviceFirmwareTarget
|
|
39
|
+
| {
|
|
40
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
41
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
42
|
+
path: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type DeviceFirmwareUpdateParams = {
|
|
46
|
+
targets?: DeviceFirmwareTargetInput[];
|
|
47
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
48
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
49
|
+
path?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type FactoryDeviceInfoSettingsParams = {
|
|
53
|
+
serial_no?: string;
|
|
54
|
+
serialNo?: string;
|
|
55
|
+
cpu_info?: string;
|
|
56
|
+
cpuInfo?: string;
|
|
57
|
+
pre_firmware?: string;
|
|
58
|
+
preFirmware?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const DEVICE_REBOOT_TYPES: Record<string, DeviceRebootType> = {
|
|
62
|
+
Normal: DeviceRebootType.Normal,
|
|
63
|
+
normal: DeviceRebootType.Normal,
|
|
64
|
+
Boardloader: DeviceRebootType.Boardloader,
|
|
65
|
+
boardloader: DeviceRebootType.Boardloader,
|
|
66
|
+
Bootloader: DeviceRebootType.Bootloader,
|
|
67
|
+
bootloader: DeviceRebootType.Bootloader,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS: TransportCallOptions = {
|
|
71
|
+
intermediateTypes: ['DeviceFirmwareInstallProgress'],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: (
|
|
75
|
+
| 'Success'
|
|
76
|
+
| 'DeviceFirmwareUpdateStatus'
|
|
77
|
+
)[] = ['Success', 'DeviceFirmwareUpdateStatus'];
|
|
78
|
+
|
|
79
|
+
export function normalizeRebootType(value: RebootTypeInput | undefined): DeviceRebootType {
|
|
80
|
+
if (typeof value === 'number') return value;
|
|
81
|
+
if (typeof value === 'string') {
|
|
82
|
+
const numeric = Number(value);
|
|
83
|
+
if (Number.isFinite(numeric)) return numeric;
|
|
84
|
+
if (value in DEVICE_REBOOT_TYPES) return DEVICE_REBOOT_TYPES[value];
|
|
85
|
+
}
|
|
86
|
+
return DeviceRebootType.Normal;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function normalizeTargetId(
|
|
90
|
+
value: DeviceFirmwareTargetType | string | number | undefined,
|
|
91
|
+
name: string
|
|
92
|
+
): DeviceFirmwareTargetType {
|
|
93
|
+
if (value === undefined || value === null) {
|
|
94
|
+
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
95
|
+
}
|
|
96
|
+
if (typeof value === 'number') {
|
|
97
|
+
if (Number.isSafeInteger(value) && value > 0) return value;
|
|
98
|
+
throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
|
|
99
|
+
}
|
|
100
|
+
const numeric = Number(value);
|
|
101
|
+
if (Number.isSafeInteger(numeric) && numeric > 0) return numeric;
|
|
102
|
+
throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function normalizeFirmwareTargets(
|
|
106
|
+
params: DeviceFirmwareUpdateParams
|
|
107
|
+
): DeviceFirmwareTarget[] {
|
|
108
|
+
const targets =
|
|
109
|
+
params.targets ??
|
|
110
|
+
(params.path
|
|
111
|
+
? [
|
|
112
|
+
{
|
|
113
|
+
target_id: params.target_id ?? params.targetId ?? 0,
|
|
114
|
+
path: params.path,
|
|
115
|
+
},
|
|
116
|
+
]
|
|
117
|
+
: []);
|
|
118
|
+
|
|
119
|
+
if (!Array.isArray(targets) || targets.length === 0) {
|
|
120
|
+
throw invalidParameter('Parameter [targets] must contain at least one firmware target.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return targets.map((target, index) => {
|
|
124
|
+
if (!target || typeof target !== 'object') {
|
|
125
|
+
throw invalidParameter(`Parameter [targets.${index}] must be an object.`);
|
|
126
|
+
}
|
|
127
|
+
const targetId = target.target_id ?? target.targetId;
|
|
128
|
+
return {
|
|
129
|
+
target_id: normalizeTargetId(targetId, `targets.${index}.target_id`),
|
|
130
|
+
path: validateNonEmptyString(target.path, `targets.${index}.path`),
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function buildTargets(params: DeviceGetDeviceInfoParams): DeviceInfoTargets | undefined {
|
|
136
|
+
if (params.targets) return params.targets;
|
|
137
|
+
|
|
138
|
+
const targets: DeviceInfoTargets = {
|
|
139
|
+
hw: params.targetHw,
|
|
140
|
+
fw: params.targetFw,
|
|
141
|
+
bt: params.targetBt,
|
|
142
|
+
se1: params.targetSe1,
|
|
143
|
+
se2: params.targetSe2,
|
|
144
|
+
se3: params.targetSe3,
|
|
145
|
+
se4: params.targetSe4,
|
|
146
|
+
status: params.targetStatus,
|
|
147
|
+
};
|
|
148
|
+
return Object.values(targets).some(value => value !== undefined) ? targets : undefined;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function buildTypes(params: DeviceGetDeviceInfoParams): DeviceInfoTypes | undefined {
|
|
152
|
+
if (params.types) return params.types;
|
|
153
|
+
|
|
154
|
+
const types: DeviceInfoTypes = {
|
|
155
|
+
version: params.includeVersion,
|
|
156
|
+
build_id: params.includeBuildId,
|
|
157
|
+
hash: params.includeHash,
|
|
158
|
+
specific: params.includeSpecific,
|
|
159
|
+
};
|
|
160
|
+
return Object.values(types).some(value => value !== undefined) ? types : undefined;
|
|
161
|
+
}
|
|
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
5
|
|
|
6
6
|
import type { ScdoGetAddress as HardwareScdoGetAddress } from '@onekeyfe/hd-transport';
|
|
7
|
-
import type { ScdoAddress, ScdoGetAddressParams } from '../../types';
|
|
7
|
+
import type { DeviceFirmwareRange, ScdoAddress, ScdoGetAddressParams } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class ScdoGetAddress extends BaseMethod<HardwareScdoGetAddress[]> {
|
|
10
10
|
hasBundle = false;
|
|
@@ -38,8 +38,12 @@ export default class ScdoGetAddress extends BaseMethod<HardwareScdoGetAddress[]>
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
getVersionRange() {
|
|
41
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
42
42
|
return {
|
|
43
|
+
pro2: {
|
|
44
|
+
min: '0.0.0',
|
|
45
|
+
unsupported: true,
|
|
46
|
+
},
|
|
43
47
|
model_touch: {
|
|
44
48
|
min: '4.10.0',
|
|
45
49
|
},
|
|
@@ -5,12 +5,12 @@ import { validateParams } from '../helpers/paramsValidator';
|
|
|
5
5
|
import { stripHexPrefix } from '../helpers/hexUtils';
|
|
6
6
|
|
|
7
7
|
import type { ScdoSignMessage as HardwareScdoSignMessage } from '@onekeyfe/hd-transport';
|
|
8
|
+
import type { DeviceFirmwareRange } from '../../types';
|
|
8
9
|
|
|
9
10
|
export default class ScdoSignMessage extends BaseMethod<HardwareScdoSignMessage> {
|
|
10
11
|
init() {
|
|
11
12
|
this.checkDeviceId = true;
|
|
12
13
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
14
|
|
|
15
15
|
// check payload
|
|
16
16
|
validateParams(this.payload, [
|
|
@@ -28,8 +28,12 @@ export default class ScdoSignMessage extends BaseMethod<HardwareScdoSignMessage>
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
getVersionRange() {
|
|
31
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
32
32
|
return {
|
|
33
|
+
pro2: {
|
|
34
|
+
min: '0.0.0',
|
|
35
|
+
unsupported: true,
|
|
36
|
+
},
|
|
33
37
|
model_touch: {
|
|
34
38
|
min: '4.10.0',
|
|
35
39
|
},
|
|
@@ -6,7 +6,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
6
6
|
import { validateParams } from '../helpers/paramsValidator';
|
|
7
7
|
import { formatAnyHex, stripHexStartZeroes } from '../helpers/hexUtils';
|
|
8
8
|
|
|
9
|
-
import type { ScdoSignTransactionParams } from '../../types';
|
|
9
|
+
import type { DeviceFirmwareRange, ScdoSignTransactionParams } from '../../types';
|
|
10
10
|
import type {
|
|
11
11
|
ScdoSignTx as HardwareScdoSignTx,
|
|
12
12
|
ScdoSignedTx,
|
|
@@ -18,7 +18,6 @@ export default class ScdoSignTransaction extends BaseMethod<HardwareScdoSignTx>
|
|
|
18
18
|
init() {
|
|
19
19
|
this.checkDeviceId = true;
|
|
20
20
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
21
|
-
this.allowUsePreInitialize = true;
|
|
22
21
|
|
|
23
22
|
// check payload
|
|
24
23
|
validateParams(this.payload, [
|
|
@@ -51,8 +50,12 @@ export default class ScdoSignTransaction extends BaseMethod<HardwareScdoSignTx>
|
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
getVersionRange() {
|
|
53
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
55
54
|
return {
|
|
55
|
+
pro2: {
|
|
56
|
+
min: '0.0.0',
|
|
57
|
+
unsupported: true,
|
|
58
|
+
},
|
|
56
59
|
model_touch: {
|
|
57
60
|
min: '4.10.0',
|
|
58
61
|
},
|
|
@@ -38,6 +38,15 @@ export default class SolGetAddress extends BaseMethod<SolanaGetAddress[]> {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
getVersionRange() {
|
|
42
|
+
return {
|
|
43
|
+
pro2: {
|
|
44
|
+
min: '0.0.0',
|
|
45
|
+
unsupported: true,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
async run() {
|
|
42
51
|
const responses: SolanaAddress[] = [];
|
|
43
52
|
|
|
@@ -10,7 +10,6 @@ export default class SolSignMessage extends BaseMethod<HardwareSolSignUnsafeMess
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -30,6 +29,10 @@ export default class SolSignMessage extends BaseMethod<HardwareSolSignUnsafeMess
|
|
|
30
29
|
|
|
31
30
|
getVersionRange() {
|
|
32
31
|
return {
|
|
32
|
+
pro2: {
|
|
33
|
+
min: '0.0.0',
|
|
34
|
+
unsupported: true,
|
|
35
|
+
},
|
|
33
36
|
pro: {
|
|
34
37
|
min: '4.12.0',
|
|
35
38
|
},
|
|
@@ -10,7 +10,6 @@ export default class SolSignOffchainMessage extends BaseMethod<HardwareSolSignOf
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -36,6 +35,10 @@ export default class SolSignOffchainMessage extends BaseMethod<HardwareSolSignOf
|
|
|
36
35
|
|
|
37
36
|
getVersionRange() {
|
|
38
37
|
return {
|
|
38
|
+
pro2: {
|
|
39
|
+
min: '0.0.0',
|
|
40
|
+
unsupported: true,
|
|
41
|
+
},
|
|
39
42
|
pro: {
|
|
40
43
|
min: '4.12.0',
|
|
41
44
|
},
|
|
@@ -13,7 +13,6 @@ export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[
|
|
|
13
13
|
init() {
|
|
14
14
|
this.checkDeviceId = true;
|
|
15
15
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
16
|
-
this.allowUsePreInitialize = true;
|
|
17
16
|
|
|
18
17
|
this.hasBundle = !!this.payload?.bundle;
|
|
19
18
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -43,6 +42,10 @@ export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[
|
|
|
43
42
|
getVersionRange() {
|
|
44
43
|
if (this.existsVersionedTx()) {
|
|
45
44
|
return {
|
|
45
|
+
pro2: {
|
|
46
|
+
min: '0.0.0',
|
|
47
|
+
unsupported: true,
|
|
48
|
+
},
|
|
46
49
|
model_mini: {
|
|
47
50
|
min: '3.1.0',
|
|
48
51
|
},
|
|
@@ -53,6 +56,10 @@ export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
return {
|
|
59
|
+
pro2: {
|
|
60
|
+
min: '0.0.0',
|
|
61
|
+
unsupported: true,
|
|
62
|
+
},
|
|
56
63
|
classic: {
|
|
57
64
|
min: '2.1.9',
|
|
58
65
|
},
|
|
@@ -10,7 +10,6 @@ export default class StarcoinSignMessage extends BaseMethod<HardwareStarcoinSign
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -10,7 +10,6 @@ export default class StarcoinSignTransaction extends BaseMethod<StarcoinSignTx>
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
|
|
|
4
4
|
import { validateParams, validateResult } from '../helpers/paramsValidator';
|
|
5
5
|
|
|
6
6
|
import type { StellarGetAddress as HardwareStellarGetAddress } from '@onekeyfe/hd-transport';
|
|
7
|
-
import type { StellarAddress, StellarGetAddressParams } from '../../types';
|
|
7
|
+
import type { DeviceFirmwareRange, StellarAddress, StellarGetAddressParams } from '../../types';
|
|
8
8
|
|
|
9
9
|
export default class StellarGetAddress extends BaseMethod<HardwareStellarGetAddress[]> {
|
|
10
10
|
hasBundle = false;
|
|
@@ -38,6 +38,15 @@ export default class StellarGetAddress extends BaseMethod<HardwareStellarGetAddr
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
42
|
+
return {
|
|
43
|
+
pro2: {
|
|
44
|
+
min: '0.0.0',
|
|
45
|
+
unsupported: true,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
async run() {
|
|
42
51
|
const responses: StellarAddress[] = [];
|
|
43
52
|
|
|
@@ -10,7 +10,11 @@ import type {
|
|
|
10
10
|
StellarSignTx as HardwareStellarSignTx,
|
|
11
11
|
StellarSignedTx,
|
|
12
12
|
} from '@onekeyfe/hd-transport';
|
|
13
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
DeviceFirmwareRange,
|
|
15
|
+
StellarOperation,
|
|
16
|
+
StellarSignTransactionParams,
|
|
17
|
+
} from '../../types';
|
|
14
18
|
|
|
15
19
|
// Firmware accepts up to 1024 bytes per chunk; 1 byte = 2 hex chars
|
|
16
20
|
const SOROBAN_CHUNK_BYTES = 1024;
|
|
@@ -28,6 +32,15 @@ export default class StellarSignTransaction extends BaseMethod<HardwareStellarSi
|
|
|
28
32
|
extSent: number;
|
|
29
33
|
};
|
|
30
34
|
|
|
35
|
+
getVersionRange(): DeviceFirmwareRange {
|
|
36
|
+
return {
|
|
37
|
+
pro2: {
|
|
38
|
+
min: '0.0.0',
|
|
39
|
+
unsupported: true,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
parseOperation = (op: StellarOperation) => {
|
|
32
45
|
switch (op.type) {
|
|
33
46
|
case 'createAccount':
|
|
@@ -218,7 +231,6 @@ export default class StellarSignTransaction extends BaseMethod<HardwareStellarSi
|
|
|
218
231
|
init() {
|
|
219
232
|
this.checkDeviceId = true;
|
|
220
233
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
221
|
-
this.allowUsePreInitialize = true;
|
|
222
234
|
|
|
223
235
|
// check payload
|
|
224
236
|
validateParams(this.payload, [
|
|
@@ -10,7 +10,6 @@ export default class SuiSignMessage extends BaseMethod<HardwareSuiSignMessage> {
|
|
|
10
10
|
init() {
|
|
11
11
|
this.checkDeviceId = true;
|
|
12
12
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
|
-
this.allowUsePreInitialize = true;
|
|
14
13
|
|
|
15
14
|
// check payload
|
|
16
15
|
validateParams(this.payload, [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
3
|
+
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
3
4
|
|
|
4
5
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
5
6
|
import { validatePath } from '../helpers/pathUtils';
|
|
@@ -9,12 +10,8 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
9
10
|
import { getDeviceFirmwareVersion, getDeviceType } from '../../utils';
|
|
10
11
|
import { DeviceModelToTypes } from '../../types';
|
|
11
12
|
|
|
12
|
-
import type {
|
|
13
|
-
|
|
14
|
-
SuiSignedTx,
|
|
15
|
-
TypedCall,
|
|
16
|
-
} from '@onekeyfe/hd-transport';
|
|
17
|
-
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
13
|
+
import type { SuiSignTx as HardwareSuiSignTx, SuiSignedTx } from '@onekeyfe/hd-transport';
|
|
14
|
+
import type { TypedCall, TypedResponseMessage } from '../../device/DeviceCommands';
|
|
18
15
|
|
|
19
16
|
type SuiSignTx = Omit<HardwareSuiSignTx, 'data_initial_chunk' | 'data_length'> & HardwareSuiSignTx;
|
|
20
17
|
|
|
@@ -22,7 +19,6 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
|
|
|
22
19
|
init() {
|
|
23
20
|
this.checkDeviceId = true;
|
|
24
21
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
25
|
-
this.allowUsePreInitialize = true;
|
|
26
22
|
|
|
27
23
|
// check payload
|
|
28
24
|
validateParams(this.payload, [
|
|
@@ -53,6 +49,13 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
|
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
supportChunkTransfer() {
|
|
52
|
+
if (
|
|
53
|
+
this.device.originalDescriptor?.protocolType === 'V2' ||
|
|
54
|
+
getDeviceType(this.device.features) === EDeviceType.Pro2
|
|
55
|
+
) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
56
59
|
const deviceType = getDeviceType(this.device.features);
|
|
57
60
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
58
61
|
|
|
@@ -85,7 +88,7 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
|
|
|
85
88
|
|
|
86
89
|
if (!data_length) {
|
|
87
90
|
// sign Done
|
|
88
|
-
return res.message;
|
|
91
|
+
return res.message as SuiSignedTx;
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
const payload = data.subarray(offset, offset + data_length);
|
|
@@ -104,7 +107,7 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
|
|
|
104
107
|
async run() {
|
|
105
108
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
106
109
|
let offset = 0;
|
|
107
|
-
let data
|
|
110
|
+
let data = Buffer.alloc(0);
|
|
108
111
|
|
|
109
112
|
if (this.supportChunkTransfer()) {
|
|
110
113
|
offset = this.chunkByteSize;
|
|
@@ -121,7 +124,6 @@ export default class SuiSignTransaction extends BaseMethod<SuiSignTx> {
|
|
|
121
124
|
...this.params,
|
|
122
125
|
});
|
|
123
126
|
|
|
124
|
-
// @ts-expect-error
|
|
125
127
|
return this.processTxRequest(typedCall, res, data, offset);
|
|
126
128
|
}
|
|
127
129
|
}
|
|
@@ -15,7 +15,6 @@ export default class TonSignData extends BaseMethod<HardwareTonSignData> {
|
|
|
15
15
|
this.strictCheckDeviceSupport = false;
|
|
16
16
|
this.checkDeviceId = true;
|
|
17
17
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
18
|
-
this.allowUsePreInitialize = true;
|
|
19
18
|
|
|
20
19
|
validateParams(this.payload, [
|
|
21
20
|
{ name: 'path', required: true },
|
|
@@ -26,7 +26,6 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
|
|
|
26
26
|
this.strictCheckDeviceSupport = true;
|
|
27
27
|
this.checkDeviceId = true;
|
|
28
28
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
29
|
-
this.allowUsePreInitialize = true;
|
|
30
29
|
|
|
31
30
|
// init params
|
|
32
31
|
validateParams(this.payload, [
|
|
@@ -11,7 +11,6 @@ export default class TonSignProof extends BaseMethod<HardwareTonSignProof> {
|
|
|
11
11
|
this.strictCheckDeviceSupport = true;
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
13
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
|
-
this.allowUsePreInitialize = true;
|
|
15
14
|
|
|
16
15
|
// init params
|
|
17
16
|
validateParams(this.payload, [
|
|
@@ -14,7 +14,6 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
|
|
|
14
14
|
init() {
|
|
15
15
|
this.checkDeviceId = true;
|
|
16
16
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
17
|
-
this.allowUsePreInitialize = true;
|
|
18
17
|
|
|
19
18
|
// check payload
|
|
20
19
|
validateParams(this.payload, [
|
|
@@ -29,7 +28,7 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
|
|
|
29
28
|
if (this.payload.messageType === 'V1' || this.payload.messageType == null) {
|
|
30
29
|
throw createDeviceNotSupportMethodError(
|
|
31
30
|
'TronSignMessage',
|
|
32
|
-
getFirmwareType(this.device
|
|
31
|
+
getFirmwareType(this.device?.features)
|
|
33
32
|
);
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -45,6 +44,10 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
|
|
|
45
44
|
|
|
46
45
|
getVersionRange() {
|
|
47
46
|
return {
|
|
47
|
+
pro2: {
|
|
48
|
+
min: '0.0.0',
|
|
49
|
+
unsupported: true,
|
|
50
|
+
},
|
|
48
51
|
model_mini: {
|
|
49
52
|
min: '2.5.0',
|
|
50
53
|
},
|
|
@@ -123,7 +123,6 @@ export default class TronSignTransaction extends BaseMethod<TronSignTx> {
|
|
|
123
123
|
init() {
|
|
124
124
|
this.checkDeviceId = true;
|
|
125
125
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
126
|
-
this.allowUsePreInitialize = true;
|
|
127
126
|
|
|
128
127
|
// check payload
|
|
129
128
|
validateParams(this.payload, [
|
|
@@ -148,6 +147,10 @@ export default class TronSignTransaction extends BaseMethod<TronSignTx> {
|
|
|
148
147
|
|
|
149
148
|
getVersionRange() {
|
|
150
149
|
return {
|
|
150
|
+
pro2: {
|
|
151
|
+
min: '0.0.0',
|
|
152
|
+
unsupported: true,
|
|
153
|
+
},
|
|
151
154
|
model_mini: {
|
|
152
155
|
min: '2.5.0',
|
|
153
156
|
},
|
|
@@ -11,7 +11,6 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
13
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
|
-
this.allowUsePreInitialize = true;
|
|
15
14
|
|
|
16
15
|
const { payload } = this;
|
|
17
16
|
validateParams(payload, [
|
|
@@ -30,7 +29,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
|
|
|
30
29
|
{ name: 'payment', type: 'object' },
|
|
31
30
|
]);
|
|
32
31
|
validateParams(transaction.payment, [
|
|
33
|
-
{ name: 'amount', type: '
|
|
32
|
+
{ name: 'amount', type: 'uint', required: true },
|
|
34
33
|
{ name: 'destination', type: 'string', required: true },
|
|
35
34
|
{ name: 'destinationTag', type: 'number' },
|
|
36
35
|
]);
|
package/src/core/RequestQueue.ts
CHANGED
|
@@ -113,20 +113,13 @@ export default class RequestQueue {
|
|
|
113
113
|
|
|
114
114
|
callbackPromise.promise.finally(() => {
|
|
115
115
|
Log.debug(`Callback task completed for connectId: ${connectId}`);
|
|
116
|
-
|
|
117
|
-
if (this.pendingCallbackTasks.get(connectId) === callbackPromise) {
|
|
118
|
-
this.pendingCallbackTasks.delete(connectId);
|
|
119
|
-
}
|
|
116
|
+
this.pendingCallbackTasks.delete(connectId);
|
|
120
117
|
});
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
public async waitForPendingCallbackTasks(
|
|
124
|
-
connectId: string,
|
|
125
|
-
exceptTask?: Deferred<void>
|
|
126
|
-
): Promise<void> {
|
|
120
|
+
public async waitForPendingCallbackTasks(connectId: string): Promise<void> {
|
|
127
121
|
const pendingTask = this.pendingCallbackTasks.get(connectId);
|
|
128
|
-
|
|
129
|
-
if (pendingTask && pendingTask !== exceptTask) {
|
|
122
|
+
if (pendingTask) {
|
|
130
123
|
Log.debug(`Waiting for pending callback task to complete for connectId: ${connectId}`);
|
|
131
124
|
await pendingTask.promise;
|
|
132
125
|
}
|