@onekeyfe/hd-core 1.2.0-alpha.65 → 1.2.0-alpha.66
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__/AllNetworkGetAddressBase.tracing.test.ts +313 -0
- package/__tests__/DeviceCommands.test.ts +59 -13
- package/__tests__/DeviceEventRegistration.test.ts +6 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +198 -3
- package/__tests__/connectSettings.test.ts +5 -47
- package/__tests__/core-initialization.test.ts +23 -0
- package/__tests__/device-connector-protocol.test.ts +81 -0
- package/__tests__/device-lifecycle-events.test.ts +105 -3
- package/__tests__/device-pool-state.test.ts +22 -0
- package/__tests__/device-settings.test.ts +39 -18
- package/__tests__/device-state-contract.test.ts +1 -0
- package/__tests__/device-state-mapper.test.ts +13 -1
- package/__tests__/device-utils.test.ts +48 -1
- package/__tests__/deviceSettings.test.ts +11 -1
- package/__tests__/deviceUploadNft.test.ts +316 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +31 -59
- package/__tests__/get-device-state.test.ts +132 -12
- package/__tests__/homescreen.test.ts +41 -1
- package/__tests__/kaspa-use-tweak-pro2.test.ts +2 -2
- package/__tests__/kaspaSignTransaction.test.ts +3 -26
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/method-protocol-support.test.ts +19 -0
- package/__tests__/open-wallet-session.test.ts +568 -37
- package/__tests__/pro2Nft.test.ts +108 -0
- package/__tests__/protocol-binding.test.ts +89 -0
- package/__tests__/protocol-v2-resources.test.ts +340 -0
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +91 -0
- package/__tests__/protocol-v2-unlock-policy.test.ts +300 -37
- package/__tests__/protocol-v2.test.ts +1506 -1097
- package/__tests__/protocolV2FileWrite.test.ts +152 -0
- package/__tests__/protocolV2UiInteraction.test.ts +63 -0
- package/__tests__/public-pro2-api-boundary.test.ts +1 -0
- package/__tests__/search-devices.test.ts +12 -3
- package/__tests__/tron-sign-message-init.test.ts +2 -2
- package/__tests__/uiProgressThrottle.test.ts +74 -0
- package/__tests__/uiPromiseRegistry.test.ts +115 -0
- package/dist/api/BaseMethod.d.ts +3 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +2 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/DetectDeviceConnectProtocol.d.ts +7 -0
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +0 -11
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +3 -7
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +13 -27
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +2 -2
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +1 -5
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +4 -11
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +0 -7
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +0 -2
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +1 -9
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +9 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -1
- package/dist/api/polkadot/networks.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +31 -0
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +2 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +1 -1
- package/dist/api/ton/TonSignProof.d.ts +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +2 -2
- package/dist/api/tron/TronSignTransaction.d.ts +1 -1
- package/dist/core/deviceEventRegistration.d.ts +2 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/uiPromiseRegistry.d.ts +6 -0
- package/dist/core/uiPromiseRegistry.d.ts.map +1 -0
- package/dist/data-manager/DataManager.d.ts +9 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- 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 +29 -6
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- 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/device/DevicePool.d.ts.map +1 -1
- package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts.map +1 -1
- package/dist/events/device.d.ts +4 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-promise.d.ts +4 -2
- package/dist/events/ui-promise.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +31 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +10 -2
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +243 -248
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3051 -3774
- package/dist/inject.d.ts +6 -1
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +0 -4
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts +30 -0
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +7 -4
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +1 -3
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +22 -0
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +6 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +3 -5
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/detectDeviceConnectProtocol.d.ts +4 -0
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/types/api/deviceUnlock.d.ts +5 -1
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +0 -6
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +2 -4
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +4 -71
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +7 -10
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +3 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +2 -2
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +38 -21
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +0 -1
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +4 -0
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts +4 -0
- package/dist/utils/homescreen.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/pro2Nft.d.ts +31 -0
- package/dist/utils/pro2Nft.d.ts.map +1 -0
- package/dist/utils/pro2Wallpaper.d.ts +10 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/dist/utils/uiProgressThrottle.d.ts +3 -0
- package/dist/utils/uiProgressThrottle.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +8 -10
- package/src/api/CheckAllFirmwareRelease.ts +59 -60
- package/src/api/DetectDeviceConnectProtocol.ts +18 -0
- package/src/api/FirmwareUpdate.ts +7 -15
- package/src/api/FirmwareUpdateV2.ts +126 -316
- package/src/api/FirmwareUpdateV3.ts +63 -265
- package/src/api/FirmwareUpdateV4.ts +597 -1005
- package/src/api/GetPassphraseState.ts +7 -1
- package/src/api/OpenWalletSession.ts +71 -17
- package/src/api/SearchDevices.ts +3 -1
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +36 -11
- package/src/api/device/DeviceSettings.ts +5 -4
- package/src/api/device/DeviceUnlock.ts +8 -3
- package/src/api/device/DeviceUpdateBootloader.ts +6 -125
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +27 -83
- package/src/api/firmware/updateBootloader.ts +4 -19
- package/src/api/firmware/uploadFirmware.ts +39 -144
- package/src/api/helpers/protocolV2FileWrite.ts +202 -63
- package/src/api/index.ts +2 -0
- package/src/api/kaspa/KaspaGetAddress.ts +1 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +2 -13
- package/src/api/polkadot/networks.ts +3 -3
- package/src/api/protocol-v2/DeviceUploadNft.ts +197 -0
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +3 -1
- package/src/api/protocol-v2/helpers.ts +1 -1
- package/src/api/solana/SolSignMessage.ts +1 -1
- package/src/api/solana/SolSignOffchainMessage.ts +1 -1
- package/src/api/solana/SolSignTransaction.ts +2 -2
- package/src/api/sui/SuiGetAddress.ts +1 -1
- package/src/api/sui/SuiGetPublicKey.ts +1 -1
- package/src/api/sui/SuiSignMessage.ts +1 -1
- package/src/api/sui/SuiSignTransaction.ts +1 -1
- package/src/api/ton/TonGetAddress.ts +1 -1
- package/src/api/ton/TonSignMessage.ts +1 -1
- package/src/api/ton/TonSignProof.ts +1 -1
- package/src/api/tron/TronSignMessage.ts +2 -2
- package/src/api/tron/TronSignTransaction.ts +1 -1
- package/src/core/deviceEventRegistration.ts +4 -0
- package/src/core/index.ts +213 -111
- package/src/core/uiPromiseRegistry.ts +63 -0
- package/src/data/messages/messages-protocol-v2.json +25 -0
- package/src/data-manager/DataManager.ts +113 -41
- package/src/data-manager/TransportManager.ts +6 -0
- package/src/data-manager/connectSettings.ts +0 -11
- package/src/device/Device.ts +274 -49
- package/src/device/DeviceCommands.ts +31 -4
- package/src/device/DeviceConnector.ts +33 -13
- package/src/device/DevicePool.ts +21 -7
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +3 -0
- package/src/events/device.ts +4 -0
- package/src/events/logBlockEvent.ts +1 -0
- package/src/events/ui-promise.ts +4 -2
- package/src/events/ui-request.ts +36 -2
- package/src/events/ui-response.ts +12 -2
- package/src/index.ts +0 -5
- package/src/inject.ts +60 -24
- package/src/lowLevelInject.ts +7 -8
- package/src/protocols/protocol-v2/features.ts +10 -7
- package/src/protocols/protocol-v2/firmware.ts +2 -0
- package/src/protocols/protocol-v2/resources.ts +390 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +46 -6
- package/src/protocols/protocol-v2/unlockPolicy.ts +1 -105
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +131 -0
- package/src/protocols/protocol-v2/walletSession.ts +214 -36
- package/src/topLevelInject.ts +7 -8
- package/src/types/api/checkAllFirmwareRelease.ts +3 -5
- package/src/types/api/detectDeviceConnectProtocol.ts +6 -0
- package/src/types/api/deviceUnlock.ts +12 -1
- package/src/types/api/deviceUpdateBootloader.ts +0 -6
- package/src/types/api/export.ts +1 -18
- package/src/types/api/firmwareUpdate.ts +6 -79
- package/src/types/api/index.ts +13 -14
- package/src/types/api/protocolV2.ts +13 -0
- package/src/types/device.ts +15 -3
- package/src/types/params.ts +7 -1
- package/src/types/settings.ts +60 -22
- package/src/utils/deviceFeaturesCompat.ts +5 -6
- package/src/utils/deviceFeaturesUtils.ts +14 -3
- package/src/utils/deviceInfoUtils.ts +2 -0
- package/src/utils/deviceSettings.ts +3 -0
- package/src/utils/homescreen.ts +32 -6
- package/src/utils/index.ts +6 -1
- package/src/utils/pro2Nft.ts +142 -0
- package/src/utils/pro2Wallpaper.ts +35 -8
- package/src/utils/uiProgressThrottle.ts +63 -0
- package/__tests__/device-initialize-timeout.test.ts +0 -56
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +0 -175
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +0 -119
- package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -70
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +0 -27
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +0 -200
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +0 -13
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +0 -394
- package/__tests__/firmware-update/firmware-update-plan.test.ts +0 -593
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +0 -213
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +0 -58
- package/__tests__/firmware-update/firmware-upload-source.test.ts +0 -70
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +0 -25
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts +0 -6
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +0 -1
- package/dist/api/firmware/FirmwarePreparationError.d.ts +0 -3
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +0 -3
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +0 -25
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +0 -32
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/dist/api/firmware/progressThrottle.d.ts +0 -3
- package/dist/api/firmware/progressThrottle.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +0 -2
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +0 -10
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +0 -9
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePlan.d.ts +0 -28
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +0 -42
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/src/api/firmware/FirmwareArtifactSource.ts +0 -278
- package/src/api/firmware/FirmwareHostBinding.ts +0 -100
- package/src/api/firmware/FirmwarePreparationError.ts +0 -12
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +0 -9
- package/src/api/firmware/FirmwareUpdatePlan.ts +0 -772
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +0 -449
- package/src/api/firmware/progressThrottle.ts +0 -44
- package/src/protocols/protocol-v2/lockedError.ts +0 -10
- package/src/protocols/protocol-v2/unlockRetry.ts +0 -109
- package/src/types/api/firmwareUpdateCapabilities.ts +0 -9
- package/src/types/api/firmwareUpdatePlan.ts +0 -38
- package/src/types/api/firmwareUpdatePreparedPlan.ts +0 -53
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EDeviceType, EFirmwareType,
|
|
1
|
+
import { EDeviceType, EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import FirmwareUpdateV2 from '../../src/api/FirmwareUpdateV2';
|
|
4
4
|
import { getBinary } from '../../src/api/firmware/getBinary';
|
|
5
|
-
import {
|
|
5
|
+
import { uploadFirmware } from '../../src/api/firmware/uploadFirmware';
|
|
6
6
|
import * as utils from '../../src/utils';
|
|
7
7
|
|
|
8
8
|
jest.mock('../../src/data/config', () => ({
|
|
@@ -18,8 +18,7 @@ jest.mock('../../src/api/firmware/getBinary', () => ({
|
|
|
18
18
|
|
|
19
19
|
jest.mock('../../src/api/firmware/uploadFirmware', () => ({
|
|
20
20
|
updateResources: jest.fn(),
|
|
21
|
-
|
|
22
|
-
uploadFirmwareFromSource: jest.fn(),
|
|
21
|
+
uploadFirmware: jest.fn(),
|
|
23
22
|
}));
|
|
24
23
|
|
|
25
24
|
jest.mock('../../src/device/DevicePool', () => ({
|
|
@@ -30,9 +29,7 @@ jest.mock('../../src/device/DevicePool', () => ({
|
|
|
30
29
|
}));
|
|
31
30
|
|
|
32
31
|
const mockGetBinary = getBinary as jest.MockedFunction<typeof getBinary>;
|
|
33
|
-
const
|
|
34
|
-
typeof uploadFirmwareFromSource
|
|
35
|
-
>;
|
|
32
|
+
const mockUploadFirmware = uploadFirmware as jest.MockedFunction<typeof uploadFirmware>;
|
|
36
33
|
|
|
37
34
|
type DeviceType = 'CLASSIC1S' | 'PURE';
|
|
38
35
|
|
|
@@ -178,26 +175,7 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
178
175
|
expect(mockGetBinary).toHaveBeenCalledTimes(1);
|
|
179
176
|
expectNoFirmwareMutationCalls(typedCall);
|
|
180
177
|
expect(acquire).not.toHaveBeenCalled();
|
|
181
|
-
expect(
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('preserves structured preparation errors before any firmware mutation', async () => {
|
|
185
|
-
const preparationError = ERRORS.TypedError(
|
|
186
|
-
HardwareErrorCode.RuntimeError,
|
|
187
|
-
'Firmware must be prepared by the external firmware host',
|
|
188
|
-
{
|
|
189
|
-
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
190
|
-
artifactName: 'firmware',
|
|
191
|
-
}
|
|
192
|
-
);
|
|
193
|
-
mockGetBinary.mockRejectedValue(preparationError);
|
|
194
|
-
const { method, typedCall, acquire } = createMethod();
|
|
195
|
-
|
|
196
|
-
await expect(method.run()).rejects.toBe(preparationError);
|
|
197
|
-
|
|
198
|
-
expectNoFirmwareMutationCalls(typedCall);
|
|
199
|
-
expect(acquire).not.toHaveBeenCalled();
|
|
200
|
-
expect(mockUploadFirmwareFromSource).not.toHaveBeenCalled();
|
|
178
|
+
expect(mockUploadFirmware).not.toHaveBeenCalled();
|
|
201
179
|
});
|
|
202
180
|
|
|
203
181
|
it.each([
|
|
@@ -238,11 +216,9 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
238
216
|
binary: firmwareBinary,
|
|
239
217
|
} as Awaited<ReturnType<typeof getBinary>>);
|
|
240
218
|
});
|
|
241
|
-
|
|
219
|
+
mockUploadFirmware.mockImplementation(() => {
|
|
242
220
|
callOrder.push('upload');
|
|
243
|
-
return Promise.resolve(
|
|
244
|
-
expectedResponse as Awaited<ReturnType<typeof uploadFirmwareFromSource>>
|
|
245
|
-
);
|
|
221
|
+
return Promise.resolve(expectedResponse as Awaited<ReturnType<typeof uploadFirmware>>);
|
|
246
222
|
});
|
|
247
223
|
const { method, typedCall } = createMethod({
|
|
248
224
|
updateType,
|
|
@@ -272,15 +248,15 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
272
248
|
},
|
|
273
249
|
})
|
|
274
250
|
);
|
|
275
|
-
expect(
|
|
251
|
+
expect(mockUploadFirmware).toHaveBeenCalledWith(
|
|
276
252
|
updateType,
|
|
277
253
|
expect.any(Function),
|
|
278
254
|
expect.any(Function),
|
|
279
255
|
method.device,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
256
|
+
{
|
|
257
|
+
payload: firmwareBinary,
|
|
258
|
+
rebootOnSuccess: true,
|
|
259
|
+
},
|
|
284
260
|
isUpdateBootloader
|
|
285
261
|
);
|
|
286
262
|
}
|
|
@@ -295,11 +271,11 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
295
271
|
binary: firmwareBinary,
|
|
296
272
|
} as Awaited<ReturnType<typeof getBinary>>);
|
|
297
273
|
});
|
|
298
|
-
|
|
274
|
+
mockUploadFirmware.mockImplementation(() => {
|
|
299
275
|
callOrder.push('upload');
|
|
300
276
|
return Promise.resolve({
|
|
301
277
|
success: true,
|
|
302
|
-
} as Awaited<ReturnType<typeof
|
|
278
|
+
} as Awaited<ReturnType<typeof uploadFirmware>>);
|
|
303
279
|
});
|
|
304
280
|
const { method, typedCall, acquire } = createMethod({
|
|
305
281
|
bootloaderMode: true,
|
|
@@ -324,9 +300,9 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
324
300
|
resolveDownload = resolve;
|
|
325
301
|
})
|
|
326
302
|
);
|
|
327
|
-
|
|
303
|
+
mockUploadFirmware.mockResolvedValue({
|
|
328
304
|
success: true,
|
|
329
|
-
} as Awaited<ReturnType<typeof
|
|
305
|
+
} as Awaited<ReturnType<typeof uploadFirmware>>);
|
|
330
306
|
const { method, typedCall } = createMethod();
|
|
331
307
|
|
|
332
308
|
const runPromise = method.run();
|
|
@@ -357,7 +333,7 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
357
333
|
|
|
358
334
|
expectNoFirmwareMutationCalls(typedCall);
|
|
359
335
|
expect(acquire).not.toHaveBeenCalled();
|
|
360
|
-
expect(
|
|
336
|
+
expect(mockUploadFirmware).not.toHaveBeenCalled();
|
|
361
337
|
});
|
|
362
338
|
|
|
363
339
|
it.each([
|
|
@@ -366,23 +342,23 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
366
342
|
])(
|
|
367
343
|
'keeps the non-empty %s binary overload and never downloads it again',
|
|
368
344
|
async (_kind, binary) => {
|
|
369
|
-
|
|
345
|
+
mockUploadFirmware.mockResolvedValue({
|
|
370
346
|
success: true,
|
|
371
|
-
} as Awaited<ReturnType<typeof
|
|
347
|
+
} as Awaited<ReturnType<typeof uploadFirmware>>);
|
|
372
348
|
const { method } = createMethod({ binary });
|
|
373
349
|
|
|
374
350
|
await method.run();
|
|
375
351
|
|
|
376
352
|
expect(mockGetBinary).not.toHaveBeenCalled();
|
|
377
|
-
expect(
|
|
353
|
+
expect(mockUploadFirmware).toHaveBeenCalledWith(
|
|
378
354
|
'firmware',
|
|
379
355
|
expect.any(Function),
|
|
380
356
|
expect.any(Function),
|
|
381
357
|
method.device,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
358
|
+
{
|
|
359
|
+
payload: binary,
|
|
360
|
+
rebootOnSuccess: true,
|
|
361
|
+
},
|
|
386
362
|
undefined
|
|
387
363
|
);
|
|
388
364
|
}
|
|
@@ -393,21 +369,17 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
393
369
|
['DataView', new DataView(new Uint8Array([9, 3, 4, 9]).buffer, 1, 2), [3, 4]],
|
|
394
370
|
['custom Buffer', createCustomBuffer(4), [1, 2, 3, 4]],
|
|
395
371
|
])('normalizes a non-empty %s before rebooting', async (_kind, binary, expectedBytes) => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
uploadedBytes = Array.from(new Uint8Array(await source.readAt(0, source.size)));
|
|
400
|
-
return {
|
|
401
|
-
success: true,
|
|
402
|
-
} as Awaited<ReturnType<typeof uploadFirmwareFromSource>>;
|
|
403
|
-
}
|
|
404
|
-
);
|
|
372
|
+
mockUploadFirmware.mockResolvedValue({
|
|
373
|
+
success: true,
|
|
374
|
+
} as Awaited<ReturnType<typeof uploadFirmware>>);
|
|
405
375
|
const { method } = createMethod({ binary });
|
|
406
376
|
|
|
407
377
|
await method.run();
|
|
408
378
|
|
|
409
379
|
expect(mockGetBinary).not.toHaveBeenCalled();
|
|
410
|
-
|
|
380
|
+
const normalizedBinary = mockUploadFirmware.mock.calls[0][4].payload;
|
|
381
|
+
expect(normalizedBinary).toBeInstanceOf(ArrayBuffer);
|
|
382
|
+
expect(Array.from(new Uint8Array(normalizedBinary))).toEqual(expectedBytes);
|
|
411
383
|
});
|
|
412
384
|
|
|
413
385
|
it.each([
|
|
@@ -425,6 +397,6 @@ describe('FirmwareUpdateV2 download-before-reboot safety', () => {
|
|
|
425
397
|
expect(mockGetBinary).not.toHaveBeenCalled();
|
|
426
398
|
expectNoFirmwareMutationCalls(typedCall);
|
|
427
399
|
expect(acquire).not.toHaveBeenCalled();
|
|
428
|
-
expect(
|
|
400
|
+
expect(mockUploadFirmware).not.toHaveBeenCalled();
|
|
429
401
|
});
|
|
430
402
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
import { DeviceType } from '@onekeyfe/hd-transport';
|
|
3
3
|
|
|
4
4
|
import { Device } from '../src/device/Device';
|
|
@@ -43,6 +43,70 @@ const getProtocolV2LoaderInfo = (mode: 'bootloader' | 'romloader') => ({
|
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
describe('getDeviceState', () => {
|
|
46
|
+
test('coalesces concurrent Protocol V2 runtime-context negotiation', async () => {
|
|
47
|
+
let resolveProtocolInfo:
|
|
48
|
+
| ((value: { message: typeof protocolV2ApplicationInfo }) => void)
|
|
49
|
+
| undefined;
|
|
50
|
+
const typedCall = jest.fn(
|
|
51
|
+
() =>
|
|
52
|
+
new Promise<{ message: typeof protocolV2ApplicationInfo }>(resolve => {
|
|
53
|
+
resolveProtocolInfo = resolve;
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
const device = createV2Device(typedCall);
|
|
57
|
+
|
|
58
|
+
const first = device.ensureProtocolV2RuntimeContext();
|
|
59
|
+
const second = device.ensureProtocolV2RuntimeContext();
|
|
60
|
+
resolveProtocolInfo?.({ message: protocolV2ApplicationInfo });
|
|
61
|
+
|
|
62
|
+
await expect(Promise.all([first, second])).resolves.toEqual([
|
|
63
|
+
protocolV2ApplicationInfo,
|
|
64
|
+
protocolV2ApplicationInfo,
|
|
65
|
+
]);
|
|
66
|
+
expect(typedCall).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
68
|
+
eventless_wallet_session: true,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('renegotiates Protocol V2 runtime context after transport disconnect', async () => {
|
|
73
|
+
const typedCall = jest.fn().mockResolvedValue({ message: protocolV2ApplicationInfo });
|
|
74
|
+
const device = createV2Device(typedCall);
|
|
75
|
+
|
|
76
|
+
await device.ensureProtocolV2RuntimeContext();
|
|
77
|
+
await device.ensureProtocolV2RuntimeContext();
|
|
78
|
+
device.markTransportDisconnected();
|
|
79
|
+
await device.ensureProtocolV2RuntimeContext();
|
|
80
|
+
|
|
81
|
+
expect(typedCall).toHaveBeenCalledTimes(2);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('rejects every waiter when runtime-context negotiation is invalidated', async () => {
|
|
85
|
+
let resolveProtocolInfo:
|
|
86
|
+
| ((value: { message: typeof protocolV2ApplicationInfo }) => void)
|
|
87
|
+
| undefined;
|
|
88
|
+
const typedCall = jest.fn(
|
|
89
|
+
() =>
|
|
90
|
+
new Promise<{ message: typeof protocolV2ApplicationInfo }>(resolve => {
|
|
91
|
+
resolveProtocolInfo = resolve;
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
const device = createV2Device(typedCall);
|
|
95
|
+
|
|
96
|
+
const first = device.ensureProtocolV2RuntimeContext();
|
|
97
|
+
const second = device.ensureProtocolV2RuntimeContext();
|
|
98
|
+
const firstExpectation = expect(first).rejects.toMatchObject({
|
|
99
|
+
errorCode: HardwareErrorCode.DeviceInitializeFailed,
|
|
100
|
+
});
|
|
101
|
+
const secondExpectation = expect(second).rejects.toMatchObject({
|
|
102
|
+
errorCode: HardwareErrorCode.DeviceInitializeFailed,
|
|
103
|
+
});
|
|
104
|
+
device.markTransportDisconnected();
|
|
105
|
+
resolveProtocolInfo?.({ message: protocolV2ApplicationInfo });
|
|
106
|
+
|
|
107
|
+
await Promise.all([firstExpectation, secondExpectation]);
|
|
108
|
+
});
|
|
109
|
+
|
|
46
110
|
test('does not expose the internal wallet session', async () => {
|
|
47
111
|
const device = createV2Device(jest.fn());
|
|
48
112
|
device.updateState({ protocol: 'V2' }, 'initialize');
|
|
@@ -159,15 +223,20 @@ describe('getDeviceState', () => {
|
|
|
159
223
|
throw new Error(`Unexpected request: ${requestType}`);
|
|
160
224
|
});
|
|
161
225
|
const device = createV2Device(typedCall);
|
|
162
|
-
device.updateState(
|
|
226
|
+
device.updateState(
|
|
227
|
+
{
|
|
228
|
+
protocol: 'V2',
|
|
229
|
+
identity: { deviceType: EDeviceType.Pro2 },
|
|
230
|
+
status: { mode },
|
|
231
|
+
raw: { protocolV2ProtocolInfo: getProtocolV2LoaderInfo(mode) },
|
|
232
|
+
},
|
|
233
|
+
'initialize'
|
|
234
|
+
);
|
|
163
235
|
|
|
164
236
|
const state = await device.getDeviceState({ refreshSections: ['status'] });
|
|
165
237
|
|
|
166
238
|
expect(state.status.mode).toBe(mode);
|
|
167
|
-
expect(typedCall.
|
|
168
|
-
'DeviceInfoGet',
|
|
169
|
-
'ProtocolInfoRequest',
|
|
170
|
-
]);
|
|
239
|
+
expect(typedCall).not.toHaveBeenCalled();
|
|
171
240
|
}
|
|
172
241
|
);
|
|
173
242
|
|
|
@@ -187,7 +256,14 @@ describe('getDeviceState', () => {
|
|
|
187
256
|
return { message: { init_states: true, unlocked: true, device_id: 'device-1' } };
|
|
188
257
|
});
|
|
189
258
|
const device = createV2Device(typedCall);
|
|
190
|
-
device.updateState(
|
|
259
|
+
device.updateState(
|
|
260
|
+
{
|
|
261
|
+
protocol: 'V2',
|
|
262
|
+
status: { mode: 'normal' },
|
|
263
|
+
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
264
|
+
},
|
|
265
|
+
'initialize'
|
|
266
|
+
);
|
|
191
267
|
|
|
192
268
|
const state = await device.getDeviceState({ refreshSections: ['status'] });
|
|
193
269
|
|
|
@@ -205,7 +281,14 @@ describe('getDeviceState', () => {
|
|
|
205
281
|
},
|
|
206
282
|
});
|
|
207
283
|
const device = createV2Device(typedCall);
|
|
208
|
-
device.updateState(
|
|
284
|
+
device.updateState(
|
|
285
|
+
{
|
|
286
|
+
protocol: 'V2',
|
|
287
|
+
status: { mode: 'normal' },
|
|
288
|
+
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
289
|
+
},
|
|
290
|
+
'initialize'
|
|
291
|
+
);
|
|
209
292
|
const onState = jest.fn();
|
|
210
293
|
device.on(DEVICE.STATE, onState);
|
|
211
294
|
|
|
@@ -250,13 +333,18 @@ describe('getDeviceState', () => {
|
|
|
250
333
|
throw new Error(`Unexpected request: ${requestType}`);
|
|
251
334
|
});
|
|
252
335
|
const device = createV2Device(typedCall);
|
|
253
|
-
device.updateState(
|
|
336
|
+
device.updateState(
|
|
337
|
+
{
|
|
338
|
+
protocol: 'V2',
|
|
339
|
+
status: { mode: 'normal' },
|
|
340
|
+
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
341
|
+
},
|
|
342
|
+
'initialize'
|
|
343
|
+
);
|
|
254
344
|
|
|
255
345
|
const state = await device.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
256
346
|
|
|
257
347
|
expect(typedCall.mock.calls.map(call => call[0])).toEqual([
|
|
258
|
-
'DeviceInfoGet',
|
|
259
|
-
'ProtocolInfoRequest',
|
|
260
348
|
'DeviceStatusGet',
|
|
261
349
|
'DeviceSettingsGet',
|
|
262
350
|
]);
|
|
@@ -288,7 +376,11 @@ describe('getDeviceState', () => {
|
|
|
288
376
|
});
|
|
289
377
|
const device = createV2Device(typedCall);
|
|
290
378
|
device.updateState(
|
|
291
|
-
{
|
|
379
|
+
{
|
|
380
|
+
protocol: 'V2',
|
|
381
|
+
status: { mode: 'normal', unlocked: true },
|
|
382
|
+
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
383
|
+
},
|
|
292
384
|
'initialize'
|
|
293
385
|
);
|
|
294
386
|
|
|
@@ -374,6 +466,34 @@ describe('getDeviceState', () => {
|
|
|
374
466
|
});
|
|
375
467
|
});
|
|
376
468
|
|
|
469
|
+
test.each([
|
|
470
|
+
EDeviceType.Classic,
|
|
471
|
+
EDeviceType.Classic1s,
|
|
472
|
+
EDeviceType.ClassicPure,
|
|
473
|
+
EDeviceType.Mini,
|
|
474
|
+
])('keeps the GetFeatures-only firmware path for %s', async deviceType => {
|
|
475
|
+
const typedCall = jest.fn().mockResolvedValue({
|
|
476
|
+
message: {
|
|
477
|
+
onekey_device_type: deviceType.toUpperCase(),
|
|
478
|
+
initialized: true,
|
|
479
|
+
onekey_firmware_version: '3.5.0',
|
|
480
|
+
se_ver: '1.1.0.2',
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
const device = createV1Device(typedCall);
|
|
484
|
+
|
|
485
|
+
const state = await device.getDeviceState({
|
|
486
|
+
refreshSections: ['identity', 'versions', 'verification'],
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
expect(typedCall.mock.calls.map(call => call[0])).toEqual(['GetFeatures']);
|
|
490
|
+
expect(state.versions).toMatchObject({
|
|
491
|
+
firmware: '3.5.0',
|
|
492
|
+
se: '1.1.0.2',
|
|
493
|
+
se01: '1.1.0.2',
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
|
|
377
497
|
test('does not clear Protocol V1 firmware details during a later runtime refresh', async () => {
|
|
378
498
|
let getFeaturesCount = 0;
|
|
379
499
|
const typedCall = jest.fn().mockImplementation((requestType: string) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
|
-
import { getHomeScreenSize } from '../src/utils/homescreen';
|
|
3
|
+
import { getHomeScreenSize, getNftSize } from '../src/utils/homescreen';
|
|
4
4
|
|
|
5
5
|
describe('getHomeScreenSize', () => {
|
|
6
6
|
it('returns the Pro 2 wallpaper dimensions', () => {
|
|
@@ -21,4 +21,44 @@ describe('getHomeScreenSize', () => {
|
|
|
21
21
|
})
|
|
22
22
|
).toBeUndefined();
|
|
23
23
|
});
|
|
24
|
+
|
|
25
|
+
it('does not reuse the wallpaper homeScreenType for Pro 2 NFT dimensions', () => {
|
|
26
|
+
expect(
|
|
27
|
+
getHomeScreenSize({
|
|
28
|
+
deviceType: EDeviceType.Pro2,
|
|
29
|
+
homeScreenType: 'Nft',
|
|
30
|
+
thumbnail: false,
|
|
31
|
+
})
|
|
32
|
+
).toEqual({ width: 604, height: 1024 });
|
|
33
|
+
expect(
|
|
34
|
+
getHomeScreenSize({
|
|
35
|
+
deviceType: EDeviceType.Pro2,
|
|
36
|
+
homeScreenType: 'Nft',
|
|
37
|
+
thumbnail: true,
|
|
38
|
+
})
|
|
39
|
+
).toBeUndefined();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('getNftSize', () => {
|
|
44
|
+
it('returns the Pro 2 NFT image and thumbnail dimensions independently', () => {
|
|
45
|
+
expect(getNftSize({ deviceType: EDeviceType.Pro2 })).toEqual({ width: 540, height: 540 });
|
|
46
|
+
expect(getNftSize({ deviceType: EDeviceType.Pro2, thumbnail: true })).toEqual({
|
|
47
|
+
width: 263,
|
|
48
|
+
height: 263,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('preserves the legacy NFT dimensions', () => {
|
|
53
|
+
expect(getNftSize({ deviceType: EDeviceType.Touch })).toEqual({ width: 480, height: 800 });
|
|
54
|
+
expect(getNftSize({ deviceType: EDeviceType.Touch, thumbnail: true })).toEqual({
|
|
55
|
+
width: 238,
|
|
56
|
+
height: 238,
|
|
57
|
+
});
|
|
58
|
+
expect(getNftSize({ deviceType: EDeviceType.Pro, thumbnail: true })).toEqual({
|
|
59
|
+
width: 226,
|
|
60
|
+
height: 226,
|
|
61
|
+
radius: 40,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
24
64
|
});
|
|
@@ -6,7 +6,7 @@ jest.mock('../src/data/config', () => ({
|
|
|
6
6
|
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
7
7
|
}));
|
|
8
8
|
|
|
9
|
-
describe('Kaspa Pro2 useTweak capability', () => {
|
|
9
|
+
describe('Kaspa Pro2 product-family useTweak capability', () => {
|
|
10
10
|
test.each([
|
|
11
11
|
['get address', KaspaGetAddress],
|
|
12
12
|
['sign transaction', KaspaSignTransaction],
|
|
@@ -14,7 +14,7 @@ describe('Kaspa Pro2 useTweak capability', () => {
|
|
|
14
14
|
const method = new Method({ id: 1, payload: {} } as never);
|
|
15
15
|
|
|
16
16
|
expect(method.getUseTweakVersionRange()).toMatchObject({
|
|
17
|
-
|
|
17
|
+
model_pro2: { min: '0.0.0' },
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -465,7 +465,7 @@ describe('KaspaSignTransaction protocol negotiation', () => {
|
|
|
465
465
|
expect(mockTypedCall.mock.calls[4][0]).toBe('KaspaTxAckInput');
|
|
466
466
|
});
|
|
467
467
|
|
|
468
|
-
describe('
|
|
468
|
+
describe('streaming error propagation', () => {
|
|
469
469
|
const PREV_ID = 'aa'.repeat(32);
|
|
470
470
|
const withRefTxs = {
|
|
471
471
|
outputs: [{ satoshis: 100000, script: SCRIPT, address: ADDRESS }],
|
|
@@ -486,7 +486,7 @@ describe('KaspaSignTransaction protocol negotiation', () => {
|
|
|
486
486
|
)
|
|
487
487
|
.mockRejectedValueOnce(error);
|
|
488
488
|
|
|
489
|
-
it('
|
|
489
|
+
it('propagates a previous-transaction id mismatch without retrying', async () => {
|
|
490
490
|
streamThenReject(
|
|
491
491
|
ERRORS.TypedError(
|
|
492
492
|
HardwareErrorCode.RuntimeError,
|
|
@@ -494,32 +494,9 @@ describe('KaspaSignTransaction protocol negotiation', () => {
|
|
|
494
494
|
)
|
|
495
495
|
);
|
|
496
496
|
|
|
497
|
-
await expect(runMethod(withRefTxs)).rejects.toMatchObject({
|
|
498
|
-
errorCode: HardwareErrorCode.KaspaPrevTxIdMismatch,
|
|
499
|
-
});
|
|
500
|
-
// Never silently re-signs without refTxs.
|
|
501
|
-
expect(mockTypedCall).toHaveBeenCalledTimes(2);
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
it('leaves an unrelated device error untouched', async () => {
|
|
505
|
-
streamThenReject(
|
|
506
|
-
ERRORS.TypedError(
|
|
507
|
-
HardwareErrorCode.RuntimeError,
|
|
508
|
-
'Failure_ProcessError,some other device error'
|
|
509
|
-
)
|
|
510
|
-
);
|
|
511
|
-
|
|
512
497
|
await expect(runMethod(withRefTxs)).rejects.toMatchObject({
|
|
513
498
|
errorCode: HardwareErrorCode.RuntimeError,
|
|
514
|
-
|
|
515
|
-
expect(mockTypedCall).toHaveBeenCalledTimes(2);
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
it('leaves user cancellation untouched', async () => {
|
|
519
|
-
streamThenReject(ERRORS.TypedError(HardwareErrorCode.ActionCancelled));
|
|
520
|
-
|
|
521
|
-
await expect(runMethod(withRefTxs)).rejects.toMatchObject({
|
|
522
|
-
errorCode: HardwareErrorCode.ActionCancelled,
|
|
499
|
+
message: expect.stringContaining('Kaspa previous transaction id mismatch'),
|
|
523
500
|
});
|
|
524
501
|
expect(mockTypedCall).toHaveBeenCalledTimes(2);
|
|
525
502
|
});
|
|
@@ -104,7 +104,7 @@ describe('getLogBlockLabel', () => {
|
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
it.each(['deviceUploadWallpaper', 'uploadPortfolio', 'fileWrite', 'fileRead'])(
|
|
107
|
+
it.each(['deviceUploadNft', 'deviceUploadWallpaper', 'uploadPortfolio', 'fileWrite', 'fileRead'])(
|
|
108
108
|
'keeps metadata and replaces binary payloads with their size for %s',
|
|
109
109
|
method => {
|
|
110
110
|
const request = { method, path: 'resource.bin', data: new Uint8Array(1024) };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { BaseMethod } from '../src/api/BaseMethod';
|
|
4
|
+
import { findMethod } from '../src/api/utils';
|
|
4
5
|
import BTCGetAddress from '../src/api/btc/BTCGetAddress';
|
|
5
6
|
import DeviceReboot from '../src/api/protocol-v2/DeviceReboot';
|
|
6
7
|
import SolGetAddress from '../src/api/solana/SolGetAddress';
|
|
@@ -20,6 +21,24 @@ class DefaultMethod extends BaseMethod {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
describe('method protocol support', () => {
|
|
24
|
+
test('creates a protocol detection method that returns only the current protocol', async () => {
|
|
25
|
+
const method = findMethod({
|
|
26
|
+
id: 6,
|
|
27
|
+
payload: {
|
|
28
|
+
method: 'detectDeviceConnectProtocol',
|
|
29
|
+
connectId: 'ble-device',
|
|
30
|
+
},
|
|
31
|
+
} as never);
|
|
32
|
+
|
|
33
|
+
method.init();
|
|
34
|
+
(method as unknown as { device: unknown }).device = {
|
|
35
|
+
getProtocol: () => 'V2',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
expect(method.getSupportedProtocols()).toEqual(['V1', 'V2']);
|
|
39
|
+
await expect(method.run()).resolves.toBe('V2');
|
|
40
|
+
});
|
|
41
|
+
|
|
23
42
|
test('defaults existing methods to Protocol V1 only', () => {
|
|
24
43
|
const method = new DefaultMethod({
|
|
25
44
|
id: 1,
|