@onekeyfe/hd-core 1.2.0-alpha.34 → 1.2.0-alpha.36
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 +74 -0
- package/__tests__/DeviceCommands.test.ts +84 -0
- package/__tests__/DeviceEventRegistration.test.ts +6 -0
- package/__tests__/device-settings.test.ts +3 -0
- package/__tests__/device-wallet-session-store.test.ts +80 -7
- package/__tests__/evmSignTransaction.test.ts +69 -0
- package/__tests__/get-device-state.test.ts +180 -40
- package/__tests__/open-wallet-session.test.ts +314 -55
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +56 -0
- package/__tests__/protocol-v2.test.ts +768 -139
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- 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/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/protocol.d.ts +3 -0
- package/dist/api/evm/protocol.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +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/device/Device.d.ts +25 -6
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +0 -1
- package/dist/device/DeviceWalletSessionStore.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/ui-request.d.ts +27 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +63 -12
- package/dist/index.js +1164 -904
- package/dist/protocols/protocol-v2/features.d.ts +17 -6
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +1 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +3 -3
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +5 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +1 -1
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +2 -2
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +2 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -0
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +1 -1
- package/src/api/FirmwareUpdateV4.ts +39 -14
- package/src/api/GetPassphraseState.ts +17 -0
- package/src/api/OpenWalletSession.ts +31 -8
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +24 -2
- package/src/api/device/DeviceUnlock.ts +1 -1
- package/src/api/evm/EVMGetAddress.ts +2 -2
- package/src/api/evm/EVMGetPublicKey.ts +2 -2
- package/src/api/evm/EVMSignMessage.ts +2 -2
- package/src/api/evm/EVMSignTransaction.ts +2 -2
- package/src/api/evm/EVMSignTypedData.ts +35 -45
- package/src/api/evm/EVMVerifyMessage.ts +2 -2
- package/src/api/evm/protocol.ts +6 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +2 -2
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +1 -1
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +3 -1
- package/src/core/deviceEventRegistration.ts +4 -0
- package/src/core/index.ts +46 -4
- package/src/data/messages/messages-protocol-v2.json +408 -485
- package/src/device/Device.ts +266 -43
- package/src/device/DeviceCommands.ts +12 -2
- package/src/device/DeviceWalletSessionStore.ts +0 -14
- package/src/deviceProfile/buildDeviceFeatures.ts +1 -1
- package/src/events/device.ts +4 -0
- package/src/events/ui-request.ts +32 -2
- package/src/protocols/protocol-v2/features.ts +65 -16
- package/src/protocols/protocol-v2/index.ts +5 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +8 -3
- package/src/protocols/protocol-v2/uiInteraction.ts +31 -5
- package/src/protocols/protocol-v2/unlockRetry.ts +51 -18
- package/src/protocols/protocol-v2/walletSession.ts +172 -64
- package/src/types/api/openWalletSession.ts +1 -1
- package/src/types/api/protocolV2.ts +2 -2
- package/src/types/device.ts +2 -0
- package/src/utils/deviceFeaturesUtils.ts +4 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
|
+
import { DeviceSessionPinType, DeviceSessionSeedDomain } from '@onekeyfe/hd-transport';
|
|
3
3
|
|
|
4
4
|
import { DEVICE } from '../../events';
|
|
5
5
|
import { assertCompleteDeviceSession } from './deviceSession';
|
|
6
|
-
import { isDeviceLockedError } from './lockedError';
|
|
7
6
|
|
|
8
|
-
import type { DeviceSessionGet } from '@onekeyfe/hd-transport';
|
|
7
|
+
import type { DeviceSessionAskPassphrase, DeviceSessionGet } from '@onekeyfe/hd-transport';
|
|
9
8
|
import type { Device } from '../../device/Device';
|
|
10
9
|
|
|
11
10
|
const HOST_PASSPHRASE_MAX_BYTES = 50;
|
|
12
11
|
|
|
12
|
+
const isWalletSessionInvalidError = (error: unknown) =>
|
|
13
|
+
typeof error === 'object' &&
|
|
14
|
+
error !== null &&
|
|
15
|
+
'errorCode' in error &&
|
|
16
|
+
(error as { errorCode?: unknown }).errorCode === HardwareErrorCode.WalletSessionInvalid;
|
|
17
|
+
|
|
13
18
|
const utf8ByteLength = (value: string): number | undefined => {
|
|
14
19
|
let length = 0;
|
|
15
20
|
for (const character of value) {
|
|
@@ -33,55 +38,69 @@ export async function refreshProtocolV2DeviceStatus(device: Device) {
|
|
|
33
38
|
return device.updateProtocolV2Status(status);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
export async function ensureProtocolV2WalletSessionUnlocked(device: Device) {
|
|
42
|
+
if (!device.isProtocolV2() || device.isBootloader?.() || device.isRomloader?.()) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await refreshProtocolV2DeviceStatus(device);
|
|
47
|
+
if (device.state?.status.unlocked !== false) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
52
|
+
source: 'unlock-coordinator',
|
|
53
|
+
reason: 'device-locked',
|
|
54
|
+
deviceOnly: true,
|
|
39
55
|
});
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const negotiateEventlessWalletSession = async (device: Device) => {
|
|
60
|
+
await device.ensureProtocolV2RuntimeContext();
|
|
40
61
|
};
|
|
41
62
|
|
|
42
|
-
const getDeviceSession = async (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
const getDeviceSession = async (
|
|
64
|
+
device: Device,
|
|
65
|
+
request: DeviceSessionGet,
|
|
66
|
+
deriveCardano?: boolean
|
|
67
|
+
) => {
|
|
68
|
+
const payload =
|
|
69
|
+
deriveCardano === undefined
|
|
70
|
+
? request
|
|
71
|
+
: {
|
|
72
|
+
...request,
|
|
73
|
+
seed_domains: [
|
|
74
|
+
DeviceSessionSeedDomain.SeedDomain_Standard,
|
|
75
|
+
...(deriveCardano ? [DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', payload);
|
|
52
79
|
};
|
|
53
80
|
|
|
54
|
-
const askDevicePassphrase = async (device: Device,
|
|
55
|
-
|
|
56
|
-
device.commands.typedCall(
|
|
57
|
-
'DeviceSessionAskPassphrase',
|
|
58
|
-
'Success',
|
|
59
|
-
passphrase ? { passphrase, on_device: false } : { on_device: true }
|
|
60
|
-
);
|
|
61
|
-
try {
|
|
62
|
-
await request();
|
|
63
|
-
} catch (error) {
|
|
64
|
-
if (!isDeviceLockedError(error)) {
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
67
|
-
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
68
|
-
await request();
|
|
69
|
-
}
|
|
81
|
+
const askDevicePassphrase = async (device: Device, requestPayload: DeviceSessionAskPassphrase) => {
|
|
82
|
+
await device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', requestPayload);
|
|
70
83
|
await refreshProtocolV2DeviceStatus(device);
|
|
71
84
|
};
|
|
72
85
|
|
|
73
|
-
const selectDeviceSession = async (
|
|
86
|
+
const selectDeviceSession = async (
|
|
87
|
+
device: Device,
|
|
88
|
+
expectedPassphraseState?: string,
|
|
89
|
+
deriveCardano?: boolean
|
|
90
|
+
) => {
|
|
74
91
|
const existsAttachPinUser = device.features?.attachToPinEnabled === true;
|
|
75
92
|
const metadata = {
|
|
76
93
|
source: 'wallet-session-coordinator' as const,
|
|
77
94
|
reason: expectedPassphraseState ? ('session-recovery' as const) : ('open-wallet' as const),
|
|
78
95
|
...(expectedPassphraseState ? { expectedPassphraseState } : {}),
|
|
79
96
|
};
|
|
97
|
+
const passphraseInteraction = device.createProtocolV2UiPhaseMetadata?.('passphrase', 'start');
|
|
80
98
|
const response = await device.commands.promptPassphrase(
|
|
81
99
|
{
|
|
82
100
|
existsAttachPinUser,
|
|
83
101
|
deviceOnly: false,
|
|
84
102
|
...metadata,
|
|
103
|
+
...(passphraseInteraction ? { interaction: passphraseInteraction } : {}),
|
|
85
104
|
},
|
|
86
105
|
{ cancelDeviceOnReject: false }
|
|
87
106
|
);
|
|
@@ -120,31 +139,51 @@ const selectDeviceSession = async (device: Device, expectedPassphraseState?: str
|
|
|
120
139
|
'Attach PIN wallet selection is unavailable on this device.'
|
|
121
140
|
);
|
|
122
141
|
}
|
|
123
|
-
device.
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
const attachPinInteraction = device.createProtocolV2UiPhaseMetadata?.('pin', 'start');
|
|
143
|
+
device.emit(DEVICE.ATTACH_PIN_ON_DEVICE, device, {
|
|
144
|
+
...metadata,
|
|
145
|
+
...(attachPinInteraction ? { interaction: attachPinInteraction } : {}),
|
|
146
|
+
});
|
|
147
|
+
await device.unlockDevice(DeviceSessionPinType.AttachToPin, {
|
|
148
|
+
emitUiEvent: false,
|
|
149
|
+
interaction: attachPinInteraction,
|
|
150
|
+
});
|
|
151
|
+
return getDeviceSession(device, {}, deriveCardano);
|
|
126
152
|
}
|
|
127
153
|
|
|
128
154
|
if (hasHostPassphrase) {
|
|
129
|
-
await askDevicePassphrase(device,
|
|
130
|
-
|
|
155
|
+
await askDevicePassphrase(device, {
|
|
156
|
+
passphrase: hostPassphrase,
|
|
157
|
+
on_device: false,
|
|
158
|
+
});
|
|
159
|
+
return getDeviceSession(device, {}, deriveCardano);
|
|
131
160
|
}
|
|
132
161
|
|
|
133
|
-
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device,
|
|
134
|
-
|
|
135
|
-
|
|
162
|
+
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, {
|
|
163
|
+
...metadata,
|
|
164
|
+
...(passphraseInteraction ? { interaction: passphraseInteraction } : {}),
|
|
165
|
+
});
|
|
166
|
+
await askDevicePassphrase(device, { on_device: true });
|
|
167
|
+
return getDeviceSession(device, {}, deriveCardano);
|
|
136
168
|
};
|
|
137
169
|
|
|
138
170
|
export async function getProtocolV2WalletSession(
|
|
139
171
|
device: Device,
|
|
140
172
|
options?: {
|
|
173
|
+
forceWalletSelection?: boolean;
|
|
174
|
+
/** @deprecated 兼容旧 getPassphraseState;新流程使用 forceWalletSelection。 */
|
|
141
175
|
initSession?: boolean;
|
|
142
176
|
expectedPassphraseState?: string;
|
|
143
177
|
onlyMainPin?: boolean;
|
|
178
|
+
selectMainWalletBeforeRestore?: boolean;
|
|
144
179
|
resumeOnly?: boolean;
|
|
180
|
+
deriveCardano?: boolean;
|
|
145
181
|
}
|
|
146
182
|
) {
|
|
147
|
-
|
|
183
|
+
const forceWalletSelection =
|
|
184
|
+
options?.forceWalletSelection === true || options?.initSession === true;
|
|
185
|
+
|
|
186
|
+
if (forceWalletSelection) {
|
|
148
187
|
if (options.onlyMainPin) {
|
|
149
188
|
device.clearStandardInternalState?.();
|
|
150
189
|
} else {
|
|
@@ -171,35 +210,100 @@ export async function getProtocolV2WalletSession(
|
|
|
171
210
|
: undefined;
|
|
172
211
|
let response;
|
|
173
212
|
let resumed = false;
|
|
213
|
+
let mainWalletSelected = false;
|
|
214
|
+
|
|
215
|
+
const clearCurrentWalletSession = () => {
|
|
216
|
+
if (options?.onlyMainPin) {
|
|
217
|
+
device.clearStandardInternalState?.();
|
|
218
|
+
} else {
|
|
219
|
+
device.clearInternalState();
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const rejectMismatchedAttachPinWallet = async () => {
|
|
224
|
+
const features = await refreshProtocolV2DeviceStatus(device);
|
|
225
|
+
if (features.unlockedAttachPin !== true) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
await device.lockDevice();
|
|
231
|
+
} catch {
|
|
232
|
+
// Reject the mismatched Attach PIN wallet even when older firmware cannot lock.
|
|
233
|
+
}
|
|
234
|
+
clearCurrentWalletSession();
|
|
235
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const selectMainWallet = async (force = false) => {
|
|
239
|
+
if (force || !mainWalletSelected) {
|
|
240
|
+
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
241
|
+
source: 'wallet-session-coordinator',
|
|
242
|
+
reason: expectedPassphraseState ? 'session-recovery' : 'open-wallet',
|
|
243
|
+
deviceOnly: true,
|
|
244
|
+
});
|
|
245
|
+
mainWalletSelected = true;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
174
248
|
|
|
175
249
|
if (options?.onlyMainPin) {
|
|
176
250
|
expectedPassphraseState = cachedStandardSession?.passphraseState;
|
|
177
251
|
if (cachedStandardSession) {
|
|
178
252
|
try {
|
|
179
|
-
if (
|
|
180
|
-
await
|
|
253
|
+
if (options?.selectMainWalletBeforeRestore) {
|
|
254
|
+
await selectMainWallet();
|
|
181
255
|
}
|
|
182
|
-
response = await getDeviceSession(
|
|
183
|
-
|
|
184
|
-
|
|
256
|
+
response = await getDeviceSession(
|
|
257
|
+
device,
|
|
258
|
+
{
|
|
259
|
+
session_id: cachedStandardSession.sessionId,
|
|
260
|
+
btc_test_address: cachedStandardSession.passphraseState,
|
|
261
|
+
},
|
|
262
|
+
options?.deriveCardano
|
|
263
|
+
);
|
|
185
264
|
resumed = true;
|
|
186
265
|
} catch (error) {
|
|
187
266
|
device.clearStandardInternalState?.();
|
|
188
|
-
|
|
267
|
+
if (!isWalletSessionInvalidError(error)) {
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
resumed = false;
|
|
189
271
|
}
|
|
190
272
|
}
|
|
191
273
|
|
|
192
274
|
if (!response) {
|
|
193
|
-
await
|
|
194
|
-
response = await getDeviceSession(device, {});
|
|
275
|
+
await selectMainWallet();
|
|
276
|
+
response = await getDeviceSession(device, {}, options?.deriveCardano);
|
|
195
277
|
}
|
|
196
278
|
} else if (cachedSessionId && expectedPassphraseState) {
|
|
197
279
|
try {
|
|
198
|
-
response = await getDeviceSession(
|
|
280
|
+
response = await getDeviceSession(
|
|
281
|
+
device,
|
|
282
|
+
{
|
|
283
|
+
session_id: cachedSessionId,
|
|
284
|
+
btc_test_address: expectedPassphraseState,
|
|
285
|
+
},
|
|
286
|
+
options?.deriveCardano
|
|
287
|
+
);
|
|
199
288
|
resumed = true;
|
|
200
289
|
} catch (error) {
|
|
201
290
|
device.clearInternalState();
|
|
202
|
-
|
|
291
|
+
if (options?.resumeOnly || !isWalletSessionInvalidError(error)) {
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
resumed = false;
|
|
295
|
+
}
|
|
296
|
+
} else if (expectedPassphraseState) {
|
|
297
|
+
try {
|
|
298
|
+
response = await getDeviceSession(
|
|
299
|
+
device,
|
|
300
|
+
{ btc_test_address: expectedPassphraseState },
|
|
301
|
+
options?.deriveCardano
|
|
302
|
+
);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
if (options?.resumeOnly || !isWalletSessionInvalidError(error)) {
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
203
307
|
}
|
|
204
308
|
}
|
|
205
309
|
|
|
@@ -208,7 +312,7 @@ export async function getProtocolV2WalletSession(
|
|
|
208
312
|
device.clearInternalState();
|
|
209
313
|
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
210
314
|
}
|
|
211
|
-
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
315
|
+
response = await selectDeviceSession(device, expectedPassphraseState, options?.deriveCardano);
|
|
212
316
|
}
|
|
213
317
|
|
|
214
318
|
let { message } = response;
|
|
@@ -224,13 +328,18 @@ export async function getProtocolV2WalletSession(
|
|
|
224
328
|
}
|
|
225
329
|
if (expectedPassphraseState && expectedPassphraseState !== message.btc_test_address) {
|
|
226
330
|
resumed = false;
|
|
331
|
+
await rejectMismatchedAttachPinWallet();
|
|
332
|
+
if (options?.resumeOnly) {
|
|
333
|
+
device.clearInternalState();
|
|
334
|
+
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
335
|
+
}
|
|
227
336
|
if (options?.onlyMainPin) {
|
|
228
337
|
device.clearStandardInternalState?.();
|
|
229
|
-
await
|
|
230
|
-
response = await getDeviceSession(device, {});
|
|
338
|
+
await selectMainWallet(true);
|
|
339
|
+
response = await getDeviceSession(device, {}, options?.deriveCardano);
|
|
231
340
|
} else {
|
|
232
341
|
device.clearInternalState();
|
|
233
|
-
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
342
|
+
response = await selectDeviceSession(device, expectedPassphraseState, options?.deriveCardano);
|
|
234
343
|
}
|
|
235
344
|
message = response.message;
|
|
236
345
|
try {
|
|
@@ -244,11 +353,8 @@ export async function getProtocolV2WalletSession(
|
|
|
244
353
|
throw error;
|
|
245
354
|
}
|
|
246
355
|
if (expectedPassphraseState !== message.btc_test_address) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
} else {
|
|
250
|
-
device.clearInternalState();
|
|
251
|
-
}
|
|
356
|
+
await rejectMismatchedAttachPinWallet();
|
|
357
|
+
clearCurrentWalletSession();
|
|
252
358
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
253
359
|
}
|
|
254
360
|
}
|
|
@@ -258,7 +364,7 @@ export async function getProtocolV2WalletSession(
|
|
|
258
364
|
message.btc_test_address,
|
|
259
365
|
device.getCurrentDeviceId(),
|
|
260
366
|
message.session_id,
|
|
261
|
-
|
|
367
|
+
forceWalletSelection ? null : cachedSessionId ?? null,
|
|
262
368
|
] as const;
|
|
263
369
|
if (options?.onlyMainPin) {
|
|
264
370
|
device.updateInternalState(...internalStateArgs, 'standard');
|
|
@@ -269,17 +375,19 @@ export async function getProtocolV2WalletSession(
|
|
|
269
375
|
return {
|
|
270
376
|
passphraseState: message.btc_test_address,
|
|
271
377
|
newSession: message.session_id,
|
|
272
|
-
unlockedAttachPin:
|
|
378
|
+
unlockedAttachPin: mainWalletSelected ? false : undefined,
|
|
273
379
|
resumed,
|
|
274
380
|
};
|
|
275
381
|
}
|
|
276
382
|
|
|
277
383
|
export async function restoreProtocolV2WalletSession(
|
|
278
384
|
device: Device,
|
|
279
|
-
expectedPassphraseState: string
|
|
385
|
+
expectedPassphraseState: string,
|
|
386
|
+
deriveCardano?: boolean
|
|
280
387
|
) {
|
|
281
388
|
return getProtocolV2WalletSession(device, {
|
|
282
389
|
expectedPassphraseState,
|
|
283
390
|
resumeOnly: true,
|
|
391
|
+
deriveCardano,
|
|
284
392
|
});
|
|
285
393
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommonParams, Response } from '../params';
|
|
2
|
-
import type {
|
|
2
|
+
import type { OnboardingStatus, Success } from '@onekeyfe/hd-transport';
|
|
3
3
|
import type { DeviceRebootParams } from '../../api/protocol-v2/helpers';
|
|
4
4
|
import type {
|
|
5
5
|
DeviceUploadWallpaperParams,
|
|
@@ -45,7 +45,7 @@ export declare function deviceReboot(
|
|
|
45
45
|
export declare function deviceGetOnboardingStatus(
|
|
46
46
|
connectId: string,
|
|
47
47
|
params?: CommonParams
|
|
48
|
-
): Response<
|
|
48
|
+
): Response<OnboardingStatus>;
|
|
49
49
|
|
|
50
50
|
export declare function deviceUploadWallpaper(
|
|
51
51
|
connectId: string,
|
package/src/types/device.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
OneKeyDeviceCommType,
|
|
8
8
|
ProtocolV2DeviceInfo,
|
|
9
9
|
DeviceStatus as ProtocolV2DeviceStatus,
|
|
10
|
+
ProtocolInfo as ProtocolV2ProtocolInfo,
|
|
10
11
|
} from '@onekeyfe/hd-transport';
|
|
11
12
|
|
|
12
13
|
export type DeviceStatus = 'available' | 'occupied' | 'used';
|
|
@@ -159,6 +160,7 @@ export type DeviceFeaturesVerify = {
|
|
|
159
160
|
export type DeviceFeaturesRaw = {
|
|
160
161
|
protocolV1Features?: PROTO.Features;
|
|
161
162
|
protocolV1OneKeyFeatures?: OnekeyFeatures;
|
|
163
|
+
protocolV2ProtocolInfo?: ProtocolV2ProtocolInfo;
|
|
162
164
|
protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
|
|
163
165
|
protocolV2DeviceStatus?: ProtocolV2DeviceStatus;
|
|
164
166
|
};
|
|
@@ -106,6 +106,7 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
106
106
|
expectPassphraseState?: string;
|
|
107
107
|
onlyMainPin?: boolean;
|
|
108
108
|
initSession?: boolean;
|
|
109
|
+
deriveCardano?: boolean;
|
|
109
110
|
}
|
|
110
111
|
) => {
|
|
111
112
|
if (device.isProtocolV2()) {
|
|
@@ -121,6 +122,7 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
121
122
|
initSession: options?.initSession,
|
|
122
123
|
expectedPassphraseState: options?.expectPassphraseState,
|
|
123
124
|
onlyMainPin: options?.onlyMainPin,
|
|
125
|
+
deriveCardano: options?.deriveCardano,
|
|
124
126
|
});
|
|
125
127
|
}
|
|
126
128
|
|
|
@@ -185,6 +187,7 @@ export const getPassphraseState = async (
|
|
|
185
187
|
expectPassphraseState?: string;
|
|
186
188
|
onlyMainPin?: boolean;
|
|
187
189
|
initSession?: boolean;
|
|
190
|
+
deriveCardano?: boolean;
|
|
188
191
|
}
|
|
189
192
|
): Promise<{
|
|
190
193
|
passphraseState: string | undefined;
|
|
@@ -205,6 +208,7 @@ export const getPassphraseState = async (
|
|
|
205
208
|
initSession: options?.initSession,
|
|
206
209
|
expectedPassphraseState: options?.expectPassphraseState,
|
|
207
210
|
onlyMainPin: options?.onlyMainPin,
|
|
211
|
+
deriveCardano: options?.deriveCardano,
|
|
208
212
|
});
|
|
209
213
|
}
|
|
210
214
|
|