@onekeyfe/hd-core 1.2.0-alpha.66 → 1.2.0-alpha.67
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 +0 -313
- package/__tests__/DeviceCommands.test.ts +13 -59
- package/__tests__/DeviceEventRegistration.test.ts +0 -6
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -198
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/device-initialize-timeout.test.ts +56 -0
- package/__tests__/device-lifecycle-events.test.ts +3 -105
- package/__tests__/device-pool-state.test.ts +0 -22
- package/__tests__/device-settings.test.ts +18 -39
- package/__tests__/device-state-contract.test.ts +0 -1
- package/__tests__/device-state-mapper.test.ts +1 -13
- package/__tests__/device-utils.test.ts +1 -48
- package/__tests__/deviceSettings.test.ts +1 -11
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/device-update-bootloader.test.ts +87 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +394 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +231 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +12 -132
- package/__tests__/homescreen.test.ts +1 -41
- package/__tests__/kaspa-use-tweak-pro2.test.ts +2 -2
- package/__tests__/kaspaSignTransaction.test.ts +26 -3
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/method-protocol-support.test.ts +0 -19
- package/__tests__/open-wallet-session.test.ts +37 -568
- package/__tests__/protocol-v2-unlock-policy.test.ts +37 -300
- package/__tests__/protocol-v2.test.ts +1153 -1458
- package/__tests__/protocolV2FileWrite.test.ts +0 -152
- package/__tests__/protocolV2UiInteraction.test.ts +0 -63
- package/__tests__/public-pro2-api-boundary.test.ts +0 -1
- package/__tests__/search-devices.test.ts +3 -12
- package/__tests__/tron-sign-message-init.test.ts +2 -2
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +10 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +27 -13
- 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 +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +11 -4
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -9
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -2
- 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/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 +0 -2
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +4 -9
- 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 +6 -29
- 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 +1 -2
- 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 +0 -4
- 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 +2 -4
- package/dist/events/ui-promise.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -31
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +2 -10
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +247 -243
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3773 -3054
- package/dist/inject.d.ts +1 -6
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +4 -0
- 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/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +4 -7
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -6
- 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 +5 -3
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -5
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -2
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +70 -4
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +10 -7
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +0 -3
- 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 +0 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +21 -38
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -4
- 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 +0 -4
- 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/pro2Wallpaper.d.ts +0 -10
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +10 -8
- package/src/api/CheckAllFirmwareRelease.ts +60 -59
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +298 -126
- package/src/api/FirmwareUpdateV3.ts +265 -63
- package/src/api/FirmwareUpdateV4.ts +1017 -602
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -71
- package/src/api/SearchDevices.ts +1 -3
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -36
- package/src/api/device/DeviceSettings.ts +4 -5
- package/src/api/device/DeviceUnlock.ts +3 -8
- package/src/api/device/DeviceUpdateBootloader.ts +125 -6
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -27
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +449 -0
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +144 -39
- package/src/api/helpers/protocolV2FileWrite.ts +63 -202
- package/src/api/index.ts +0 -2
- package/src/api/kaspa/KaspaGetAddress.ts +1 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +13 -2
- package/src/api/polkadot/networks.ts +3 -3
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- 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 +0 -4
- package/src/core/index.ts +111 -213
- package/src/data/messages/messages-protocol-v2.json +0 -25
- package/src/data-manager/DataManager.ts +41 -113
- package/src/data-manager/TransportManager.ts +0 -6
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +49 -274
- package/src/device/DeviceCommands.ts +4 -31
- package/src/device/DeviceConnector.ts +13 -33
- package/src/device/DevicePool.ts +7 -21
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +0 -3
- package/src/events/device.ts +0 -4
- package/src/events/logBlockEvent.ts +0 -1
- package/src/events/ui-promise.ts +2 -4
- package/src/events/ui-request.ts +2 -36
- package/src/events/ui-response.ts +2 -12
- package/src/index.ts +5 -0
- package/src/inject.ts +24 -60
- package/src/lowLevelInject.ts +8 -7
- package/src/protocols/protocol-v2/features.ts +7 -10
- package/src/protocols/protocol-v2/firmware.ts +0 -2
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +6 -46
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
- package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
- package/src/protocols/protocol-v2/walletSession.ts +36 -214
- package/src/topLevelInject.ts +8 -7
- package/src/types/api/checkAllFirmwareRelease.ts +5 -3
- package/src/types/api/deviceUnlock.ts +1 -12
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -1
- package/src/types/api/firmwareUpdate.ts +78 -6
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -13
- package/src/types/api/protocolV2.ts +0 -13
- package/src/types/device.ts +3 -15
- package/src/types/params.ts +1 -7
- package/src/types/settings.ts +22 -60
- package/src/utils/deviceFeaturesCompat.ts +6 -5
- package/src/utils/deviceFeaturesUtils.ts +3 -14
- package/src/utils/deviceInfoUtils.ts +0 -2
- package/src/utils/deviceSettings.ts +0 -3
- package/src/utils/homescreen.ts +6 -32
- package/src/utils/index.ts +1 -6
- package/src/utils/pro2Wallpaper.ts +8 -35
- package/__tests__/core-initialization.test.ts +0 -23
- package/__tests__/device-connector-protocol.test.ts +0 -81
- package/__tests__/deviceUploadNft.test.ts +0 -316
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-binding.test.ts +0 -89
- package/__tests__/protocol-v2-resources.test.ts +0 -340
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/__tests__/uiPromiseRegistry.test.ts +0 -115
- package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
- package/dist/core/uiPromiseRegistry.d.ts +0 -6
- package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/resources.d.ts +0 -30
- package/dist/protocols/protocol-v2/resources.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
- package/dist/types/api/detectDeviceConnectProtocol.d.ts +0 -4
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/utils/pro2Nft.d.ts +0 -31
- package/dist/utils/pro2Nft.d.ts.map +0 -1
- package/dist/utils/uiProgressThrottle.d.ts +0 -3
- package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
- package/src/api/DetectDeviceConnectProtocol.ts +0 -18
- package/src/api/protocol-v2/DeviceUploadNft.ts +0 -197
- package/src/core/uiPromiseRegistry.ts +0 -63
- package/src/protocols/protocol-v2/resources.ts +0 -390
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -131
- package/src/types/api/detectDeviceConnectProtocol.ts +0 -6
- package/src/utils/pro2Nft.ts +0 -142
- package/src/utils/uiProgressThrottle.ts +0 -63
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import AllNetworkGetAddressBase from '../src/api/allnetwork/AllNetworkGetAddressBase';
|
|
2
|
-
import AllNetworkGetAddress from '../src/api/allnetwork/AllNetworkGetAddress';
|
|
3
2
|
import { findMethod } from '../src/api/utils';
|
|
4
3
|
import { getActiveRequestsByDeviceInstance } from '../src/utils/tracing';
|
|
5
4
|
|
|
@@ -19,317 +18,6 @@ class TestAllNetworkMethod extends AllNetworkGetAddressBase {
|
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
describe('AllNetworkGetAddressBase tracing', () => {
|
|
22
|
-
test('resumes a Protocol V2 hidden wallet before running a nested chain method', async () => {
|
|
23
|
-
const calls: string[] = [];
|
|
24
|
-
const checkPassphraseStateSafety = jest.fn().mockImplementation(() => {
|
|
25
|
-
calls.push('resume-hidden-session');
|
|
26
|
-
return Promise.resolve(true);
|
|
27
|
-
});
|
|
28
|
-
const innerMethod = {
|
|
29
|
-
checkSafetyLevelOnTestNet: jest.fn().mockResolvedValue(false),
|
|
30
|
-
connectId: 'connect-id',
|
|
31
|
-
deviceId: 'device-id',
|
|
32
|
-
getVersionRange: jest.fn().mockReturnValue({}),
|
|
33
|
-
assertProtocolSupported: jest.fn(),
|
|
34
|
-
init: jest.fn(),
|
|
35
|
-
name: 'evmGetAddress',
|
|
36
|
-
responseID: 43,
|
|
37
|
-
unlockPolicy: 'unlock-before-run',
|
|
38
|
-
run: jest.fn().mockImplementation(() => {
|
|
39
|
-
calls.push('run-chain-method');
|
|
40
|
-
return Promise.resolve([{ address: '0xhidden' }]);
|
|
41
|
-
}),
|
|
42
|
-
setDevice: jest.fn(),
|
|
43
|
-
strictCheckDeviceSupport: false,
|
|
44
|
-
};
|
|
45
|
-
(findMethod as jest.Mock).mockReturnValue(innerMethod);
|
|
46
|
-
const method = new TestAllNetworkMethod({
|
|
47
|
-
id: 1,
|
|
48
|
-
payload: {
|
|
49
|
-
method: 'allNetworkGetAddress',
|
|
50
|
-
connectId: 'connect-id',
|
|
51
|
-
deviceId: 'device-id',
|
|
52
|
-
passphraseState: 'hidden-state',
|
|
53
|
-
bundle: [],
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
method.protocolV2UnlockContext = { preflightCompleted: true };
|
|
57
|
-
const typedCall = jest.fn();
|
|
58
|
-
method.device = {
|
|
59
|
-
checkPassphraseStateSafety,
|
|
60
|
-
commands: {
|
|
61
|
-
typedCall,
|
|
62
|
-
},
|
|
63
|
-
getCurrentFirmwareType: jest.fn(),
|
|
64
|
-
getProtocol: jest.fn().mockReturnValue('V2'),
|
|
65
|
-
getCurrentFirmwareVersionString: jest.fn().mockReturnValue('1.0.0'),
|
|
66
|
-
getCurrentMethodVersionRange: jest
|
|
67
|
-
.fn()
|
|
68
|
-
.mockImplementation((getRange: (type: string) => unknown) => getRange('pro2')),
|
|
69
|
-
instanceId: 'device-instance',
|
|
70
|
-
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
71
|
-
isBootloader: jest.fn().mockReturnValue(false),
|
|
72
|
-
isRomloader: jest.fn().mockReturnValue(false),
|
|
73
|
-
off: jest.fn(),
|
|
74
|
-
on: jest.fn(),
|
|
75
|
-
state: { status: { unlocked: true } },
|
|
76
|
-
updateProtocolV2Status: jest.fn(),
|
|
77
|
-
} as any;
|
|
78
|
-
|
|
79
|
-
await method.callMethod(
|
|
80
|
-
'evmGetAddress',
|
|
81
|
-
{
|
|
82
|
-
bundle: [
|
|
83
|
-
{
|
|
84
|
-
_originRequestParams: {
|
|
85
|
-
network: 'evm',
|
|
86
|
-
path: "m/44'/60'/0'/0/0",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
0
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
expect(checkPassphraseStateSafety).toHaveBeenCalledWith(
|
|
95
|
-
'hidden-state',
|
|
96
|
-
false,
|
|
97
|
-
undefined,
|
|
98
|
-
false
|
|
99
|
-
);
|
|
100
|
-
expect(calls).toEqual(['resume-hidden-session', 'run-chain-method']);
|
|
101
|
-
expect(typedCall).not.toHaveBeenCalled();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test('resumes a Protocol V2 Cardano hidden wallet with the Cardano seed domain', async () => {
|
|
105
|
-
const calls: string[] = [];
|
|
106
|
-
const checkPassphraseStateSafety = jest.fn().mockImplementation(() => {
|
|
107
|
-
calls.push('resume-cardano-session');
|
|
108
|
-
return Promise.resolve(true);
|
|
109
|
-
});
|
|
110
|
-
const innerMethod = {
|
|
111
|
-
checkSafetyLevelOnTestNet: jest.fn().mockResolvedValue(false),
|
|
112
|
-
connectId: 'connect-id',
|
|
113
|
-
deviceId: 'device-id',
|
|
114
|
-
getVersionRange: jest.fn().mockReturnValue({}),
|
|
115
|
-
assertProtocolSupported: jest.fn(),
|
|
116
|
-
init: jest.fn(),
|
|
117
|
-
name: 'cardanoGetAddress',
|
|
118
|
-
responseID: 45,
|
|
119
|
-
unlockPolicy: 'unlock-before-run',
|
|
120
|
-
run: jest.fn().mockImplementation(() => {
|
|
121
|
-
calls.push('run-cardano-method');
|
|
122
|
-
return Promise.resolve([{ address: 'addr1hidden' }]);
|
|
123
|
-
}),
|
|
124
|
-
setDevice: jest.fn(),
|
|
125
|
-
strictCheckDeviceSupport: false,
|
|
126
|
-
};
|
|
127
|
-
(findMethod as jest.Mock).mockReturnValue(innerMethod);
|
|
128
|
-
const method = new TestAllNetworkMethod({
|
|
129
|
-
id: 5,
|
|
130
|
-
payload: {
|
|
131
|
-
method: 'allNetworkGetAddress',
|
|
132
|
-
connectId: 'connect-id',
|
|
133
|
-
deviceId: 'device-id',
|
|
134
|
-
passphraseState: 'hidden-state',
|
|
135
|
-
bundle: [],
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
method.protocolV2UnlockContext = { preflightCompleted: true };
|
|
139
|
-
const typedCall = jest.fn();
|
|
140
|
-
method.device = {
|
|
141
|
-
checkPassphraseStateSafety,
|
|
142
|
-
commands: {
|
|
143
|
-
typedCall,
|
|
144
|
-
},
|
|
145
|
-
getCurrentFirmwareType: jest.fn(),
|
|
146
|
-
getProtocol: jest.fn().mockReturnValue('V2'),
|
|
147
|
-
getCurrentFirmwareVersionString: jest.fn().mockReturnValue('1.0.0'),
|
|
148
|
-
getCurrentMethodVersionRange: jest
|
|
149
|
-
.fn()
|
|
150
|
-
.mockImplementation((getRange: (type: string) => unknown) => getRange('pro2')),
|
|
151
|
-
instanceId: 'device-instance',
|
|
152
|
-
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
153
|
-
isBootloader: jest.fn().mockReturnValue(false),
|
|
154
|
-
isRomloader: jest.fn().mockReturnValue(false),
|
|
155
|
-
off: jest.fn(),
|
|
156
|
-
on: jest.fn(),
|
|
157
|
-
state: { status: { unlocked: true } },
|
|
158
|
-
updateProtocolV2Status: jest.fn(),
|
|
159
|
-
} as any;
|
|
160
|
-
|
|
161
|
-
await method.callMethod(
|
|
162
|
-
'cardanoGetAddress',
|
|
163
|
-
{
|
|
164
|
-
bundle: [
|
|
165
|
-
{
|
|
166
|
-
_originRequestParams: {
|
|
167
|
-
network: 'ada',
|
|
168
|
-
path: "m/1852'/1815'/0'/0/0",
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
},
|
|
173
|
-
0
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
expect(checkPassphraseStateSafety).toHaveBeenCalledWith('hidden-state', false, undefined, true);
|
|
177
|
-
expect(calls).toEqual(['resume-cardano-session', 'run-cardano-method']);
|
|
178
|
-
expect(typedCall).not.toHaveBeenCalled();
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test('resumes a Protocol V2 standard wallet before running a nested chain method', async () => {
|
|
182
|
-
const calls: string[] = [];
|
|
183
|
-
const checkPassphraseStateSafety = jest.fn().mockImplementation(() => {
|
|
184
|
-
calls.push('resume-standard-session');
|
|
185
|
-
return Promise.resolve(true);
|
|
186
|
-
});
|
|
187
|
-
const innerMethod = {
|
|
188
|
-
checkSafetyLevelOnTestNet: jest.fn().mockResolvedValue(false),
|
|
189
|
-
connectId: 'connect-id',
|
|
190
|
-
deviceId: 'device-id',
|
|
191
|
-
getVersionRange: jest.fn().mockReturnValue({}),
|
|
192
|
-
assertProtocolSupported: jest.fn(),
|
|
193
|
-
init: jest.fn(),
|
|
194
|
-
name: 'evmGetAddress',
|
|
195
|
-
responseID: 44,
|
|
196
|
-
unlockPolicy: 'unlock-before-run',
|
|
197
|
-
run: jest.fn().mockImplementation(() => {
|
|
198
|
-
calls.push('run-chain-method');
|
|
199
|
-
return Promise.resolve([{ address: '0xstandard' }]);
|
|
200
|
-
}),
|
|
201
|
-
setDevice: jest.fn(),
|
|
202
|
-
strictCheckDeviceSupport: false,
|
|
203
|
-
};
|
|
204
|
-
(findMethod as jest.Mock).mockReturnValue(innerMethod);
|
|
205
|
-
const method = new TestAllNetworkMethod({
|
|
206
|
-
id: 2,
|
|
207
|
-
payload: {
|
|
208
|
-
method: 'allNetworkGetAddress',
|
|
209
|
-
connectId: 'connect-id',
|
|
210
|
-
deviceId: 'device-id',
|
|
211
|
-
useEmptyPassphrase: true,
|
|
212
|
-
bundle: [],
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
method.protocolV2UnlockContext = { preflightCompleted: true };
|
|
216
|
-
const typedCall = jest.fn();
|
|
217
|
-
method.device = {
|
|
218
|
-
checkPassphraseStateSafety,
|
|
219
|
-
commands: {
|
|
220
|
-
typedCall,
|
|
221
|
-
},
|
|
222
|
-
getCurrentFirmwareType: jest.fn(),
|
|
223
|
-
getProtocol: jest.fn().mockReturnValue('V2'),
|
|
224
|
-
getCurrentFirmwareVersionString: jest.fn().mockReturnValue('1.0.0'),
|
|
225
|
-
getCurrentMethodVersionRange: jest
|
|
226
|
-
.fn()
|
|
227
|
-
.mockImplementation((getRange: (type: string) => unknown) => getRange('pro2')),
|
|
228
|
-
instanceId: 'device-instance',
|
|
229
|
-
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
230
|
-
isBootloader: jest.fn().mockReturnValue(false),
|
|
231
|
-
isRomloader: jest.fn().mockReturnValue(false),
|
|
232
|
-
off: jest.fn(),
|
|
233
|
-
on: jest.fn(),
|
|
234
|
-
state: { status: { unlocked: true } },
|
|
235
|
-
updateProtocolV2Status: jest.fn(),
|
|
236
|
-
} as any;
|
|
237
|
-
|
|
238
|
-
await method.callMethod(
|
|
239
|
-
'evmGetAddress',
|
|
240
|
-
{
|
|
241
|
-
bundle: [
|
|
242
|
-
{
|
|
243
|
-
_originRequestParams: {
|
|
244
|
-
network: 'evm',
|
|
245
|
-
path: "m/44'/60'/0'/0/0",
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
},
|
|
250
|
-
0
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
expect(checkPassphraseStateSafety).toHaveBeenCalledWith(undefined, true, undefined, false);
|
|
254
|
-
expect(calls).toEqual(['resume-standard-session', 'run-chain-method']);
|
|
255
|
-
expect(typedCall).not.toHaveBeenCalled();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
test('runs Protocol V2 addresses one at a time so each command receives a wallet session', async () => {
|
|
259
|
-
const method = new AllNetworkGetAddress({
|
|
260
|
-
id: 3,
|
|
261
|
-
payload: {
|
|
262
|
-
method: 'allNetworkGetAddress',
|
|
263
|
-
connectId: 'connect-id',
|
|
264
|
-
deviceId: 'device-id',
|
|
265
|
-
useEmptyPassphrase: true,
|
|
266
|
-
bundle: [
|
|
267
|
-
{ network: 'evm', path: "m/44'/60'/0'/0/0" },
|
|
268
|
-
{ network: 'evm', path: "m/44'/60'/0'/0/1" },
|
|
269
|
-
],
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
method.device = {
|
|
273
|
-
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
274
|
-
} as any;
|
|
275
|
-
method.postMessage = jest.fn();
|
|
276
|
-
const callMethod = jest
|
|
277
|
-
.fn()
|
|
278
|
-
.mockResolvedValueOnce([{ payload: { address: '0x1' }, success: true }])
|
|
279
|
-
.mockResolvedValueOnce([{ payload: { address: '0x2' }, success: true }]);
|
|
280
|
-
method.callMethod = callMethod;
|
|
281
|
-
|
|
282
|
-
await method.getAllNetworkAddress(7);
|
|
283
|
-
|
|
284
|
-
expect(callMethod).toHaveBeenCalledTimes(2);
|
|
285
|
-
expect(callMethod).toHaveBeenNthCalledWith(
|
|
286
|
-
1,
|
|
287
|
-
'evmGetAddress',
|
|
288
|
-
expect.objectContaining({ bundle: [expect.any(Object)] }),
|
|
289
|
-
7
|
|
290
|
-
);
|
|
291
|
-
expect(callMethod).toHaveBeenNthCalledWith(
|
|
292
|
-
2,
|
|
293
|
-
'evmGetAddress',
|
|
294
|
-
expect.objectContaining({ bundle: [expect.any(Object)] }),
|
|
295
|
-
7
|
|
296
|
-
);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test('keeps same-method address batching for Protocol V1', async () => {
|
|
300
|
-
const method = new AllNetworkGetAddress({
|
|
301
|
-
id: 4,
|
|
302
|
-
payload: {
|
|
303
|
-
method: 'allNetworkGetAddress',
|
|
304
|
-
connectId: 'connect-id',
|
|
305
|
-
deviceId: 'device-id',
|
|
306
|
-
useEmptyPassphrase: true,
|
|
307
|
-
bundle: [
|
|
308
|
-
{ network: 'evm', path: "m/44'/60'/0'/0/0" },
|
|
309
|
-
{ network: 'evm', path: "m/44'/60'/0'/0/1" },
|
|
310
|
-
],
|
|
311
|
-
},
|
|
312
|
-
});
|
|
313
|
-
method.device = {
|
|
314
|
-
isProtocolV2: jest.fn().mockReturnValue(false),
|
|
315
|
-
} as any;
|
|
316
|
-
method.postMessage = jest.fn();
|
|
317
|
-
const callMethod = jest.fn().mockResolvedValue([
|
|
318
|
-
{ payload: { address: '0x1' }, success: true },
|
|
319
|
-
{ payload: { address: '0x2' }, success: true },
|
|
320
|
-
]);
|
|
321
|
-
method.callMethod = callMethod;
|
|
322
|
-
|
|
323
|
-
await method.getAllNetworkAddress(7);
|
|
324
|
-
|
|
325
|
-
expect(callMethod).toHaveBeenCalledTimes(1);
|
|
326
|
-
expect(callMethod).toHaveBeenCalledWith(
|
|
327
|
-
'evmGetAddress',
|
|
328
|
-
expect.objectContaining({ bundle: [expect.any(Object), expect.any(Object)] }),
|
|
329
|
-
7
|
|
330
|
-
);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
21
|
test('releases the nested request context when an unhandled error escapes', async () => {
|
|
334
22
|
const deviceInstanceId = 'device-instance';
|
|
335
23
|
const innerMethod = {
|
|
@@ -363,7 +51,6 @@ describe('AllNetworkGetAddressBase tracing', () => {
|
|
|
363
51
|
getCurrentMethodVersionRange: jest
|
|
364
52
|
.fn()
|
|
365
53
|
.mockImplementation((getRange: (type: string) => unknown) => getRange('classic')),
|
|
366
|
-
isProtocolV2: jest.fn().mockReturnValue(false),
|
|
367
54
|
off: jest.fn(),
|
|
368
55
|
on: jest.fn(),
|
|
369
56
|
} as any;
|
|
@@ -125,51 +125,6 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
125
125
|
expect(JSON.stringify(log.messages)).not.toContain('secret-wallet-address');
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
it('logs the sanitized DeviceFirmwareUpdateStatus response payload', async () => {
|
|
129
|
-
const commands = createCommands();
|
|
130
|
-
const log = getLogger(LoggerNames.DeviceCommands);
|
|
131
|
-
log.messages.length = 0;
|
|
132
|
-
|
|
133
|
-
await expect(
|
|
134
|
-
commands._filterCommonTypes(
|
|
135
|
-
{
|
|
136
|
-
type: 'DeviceFirmwareUpdateStatus',
|
|
137
|
-
message: {
|
|
138
|
-
records: [
|
|
139
|
-
{
|
|
140
|
-
target_id: 4,
|
|
141
|
-
status: 2,
|
|
142
|
-
payload_version: 0x010203,
|
|
143
|
-
path: 'vol0:/application_p1.bin',
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
} as any,
|
|
148
|
-
'DeviceFirmwareUpdateStatusGet'
|
|
149
|
-
)
|
|
150
|
-
).resolves.toMatchObject({ type: 'DeviceFirmwareUpdateStatus' });
|
|
151
|
-
|
|
152
|
-
expect(log.messages.at(-1)?.message).toEqual([
|
|
153
|
-
'_filterCommonTypes: ',
|
|
154
|
-
{
|
|
155
|
-
request: 'DeviceFirmwareUpdateStatusGet',
|
|
156
|
-
response: {
|
|
157
|
-
type: 'DeviceFirmwareUpdateStatus',
|
|
158
|
-
message: {
|
|
159
|
-
records: [
|
|
160
|
-
{
|
|
161
|
-
target_id: 4,
|
|
162
|
-
status: 2,
|
|
163
|
-
payload_version: 0x010203,
|
|
164
|
-
path: 'vol0:/application_p1.bin',
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
]);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
128
|
it('maps an invalid DeviceSessionGet resume to WalletSessionInvalid', async () => {
|
|
174
129
|
const commands = createCommands();
|
|
175
130
|
|
|
@@ -363,9 +318,9 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
363
318
|
}
|
|
364
319
|
);
|
|
365
320
|
|
|
366
|
-
it.each(['
|
|
367
|
-
'
|
|
368
|
-
async
|
|
321
|
+
it.each(['Cancelled', 'User cancelled typed data signing'])(
|
|
322
|
+
'maps the Protocol V2 MP engine cancellation response "%s" to ActionCancelled',
|
|
323
|
+
async message => {
|
|
369
324
|
const commands = createCommands();
|
|
370
325
|
|
|
371
326
|
await expect(
|
|
@@ -375,13 +330,18 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
375
330
|
message: {
|
|
376
331
|
code: 'Failure_ProcessError',
|
|
377
332
|
subcode: 1,
|
|
378
|
-
message
|
|
333
|
+
message,
|
|
379
334
|
},
|
|
380
335
|
} as any,
|
|
381
|
-
|
|
336
|
+
'SignTx'
|
|
382
337
|
)
|
|
383
338
|
).rejects.toMatchObject({
|
|
384
|
-
errorCode: HardwareErrorCode.
|
|
339
|
+
errorCode: HardwareErrorCode.ActionCancelled,
|
|
340
|
+
params: {
|
|
341
|
+
failureCode: 'Failure_ProcessError',
|
|
342
|
+
subcode: 1,
|
|
343
|
+
firmwareMessage: message,
|
|
344
|
+
},
|
|
385
345
|
});
|
|
386
346
|
}
|
|
387
347
|
);
|
|
@@ -396,7 +356,6 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
396
356
|
type: 'Failure',
|
|
397
357
|
message: {
|
|
398
358
|
code: 'Failure_ProcessError',
|
|
399
|
-
subcode: 1,
|
|
400
359
|
message: 'Cancelled on device',
|
|
401
360
|
},
|
|
402
361
|
} as any,
|
|
@@ -407,7 +366,7 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
407
366
|
});
|
|
408
367
|
});
|
|
409
368
|
|
|
410
|
-
it('
|
|
369
|
+
it('keeps an unrecognized Protocol V2 process subcode generic', async () => {
|
|
411
370
|
const commands = createCommands();
|
|
412
371
|
|
|
413
372
|
await expect(
|
|
@@ -423,12 +382,7 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
423
382
|
'DeviceSettingsPageShow'
|
|
424
383
|
)
|
|
425
384
|
).rejects.toMatchObject({
|
|
426
|
-
errorCode: HardwareErrorCode.
|
|
427
|
-
params: {
|
|
428
|
-
failureCode: 'Failure_ProcessError',
|
|
429
|
-
subcode: 1,
|
|
430
|
-
firmwareMessage: 'Another process error',
|
|
431
|
-
},
|
|
385
|
+
errorCode: HardwareErrorCode.RuntimeError,
|
|
432
386
|
});
|
|
433
387
|
});
|
|
434
388
|
|
|
@@ -3,8 +3,6 @@ import { registerHardwareUiEventListeners } from '../src/core/deviceEventRegistr
|
|
|
3
3
|
|
|
4
4
|
const handlers = {
|
|
5
5
|
pin: jest.fn(),
|
|
6
|
-
pinOnDevice: jest.fn(),
|
|
7
|
-
pinOnDeviceComplete: jest.fn(),
|
|
8
6
|
button: jest.fn(),
|
|
9
7
|
passphrase: jest.fn(),
|
|
10
8
|
passphraseOnDevice: jest.fn(),
|
|
@@ -23,8 +21,6 @@ describe('hardware UI event registration', () => {
|
|
|
23
21
|
expect(registerHardwareUiEventListeners(device as any, handlers)).toBe(true);
|
|
24
22
|
expect(device.on.mock.calls.map(([type]) => type)).toEqual([
|
|
25
23
|
DEVICE.PIN,
|
|
26
|
-
DEVICE.PIN_ON_DEVICE,
|
|
27
|
-
DEVICE.PIN_ON_DEVICE_COMPLETE,
|
|
28
24
|
DEVICE.BUTTON,
|
|
29
25
|
DEVICE.PASSPHRASE,
|
|
30
26
|
DEVICE.PASSPHRASE_ON_DEVICE,
|
|
@@ -38,8 +34,6 @@ describe('hardware UI event registration', () => {
|
|
|
38
34
|
expect(registerHardwareUiEventListeners(device as any, handlers)).toBe(true);
|
|
39
35
|
expect(device.on.mock.calls.map(([type]) => type)).toEqual([
|
|
40
36
|
DEVICE.PIN,
|
|
41
|
-
DEVICE.PIN_ON_DEVICE,
|
|
42
|
-
DEVICE.PIN_ON_DEVICE_COMPLETE,
|
|
43
37
|
DEVICE.BUTTON,
|
|
44
38
|
DEVICE.PASSPHRASE,
|
|
45
39
|
DEVICE.PASSPHRASE_ON_DEVICE,
|