@onekeyfe/hd-core 1.0.34-alpha.0 → 1.0.34-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/BaseMethod.d.ts +1 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts +3 -1
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +7 -0
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +9 -3
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +7 -5
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/device.d.ts +3 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +3 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +1 -0
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +27 -12
- package/dist/index.js +322 -170
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +4 -0
- package/dist/types/api/deviceUnlock.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +16 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +0 -2
- package/dist/utils/logger.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 +3 -2
- package/src/api/CheckAllFirmwareRelease.ts +1 -1
- package/src/api/CheckBLEFirmwareRelease.ts +3 -3
- package/src/api/CheckBootloaderRelease.ts +1 -1
- package/src/api/CheckBridgeRelease.ts +1 -1
- package/src/api/CheckFirmwareRelease.ts +3 -3
- package/src/api/CipherKeyValue.ts +1 -1
- package/src/api/FirmwareUpdate.ts +1 -1
- package/src/api/FirmwareUpdateV2.ts +1 -1
- package/src/api/FirmwareUpdateV3.ts +1 -1
- package/src/api/GetFeatures.ts +3 -3
- package/src/api/GetOnekeyFeatures.ts +3 -3
- package/src/api/GetPassphraseState.ts +20 -4
- package/src/api/alephium/AlephiumGetAddress.ts +1 -1
- package/src/api/alephium/AlephiumSignMessage.ts +1 -1
- package/src/api/alephium/AlephiumSignTransaction.ts +1 -1
- package/src/api/algo/AlgoGetAddress.ts +1 -1
- package/src/api/algo/AlgoSignTransaction.ts +1 -1
- package/src/api/allnetwork/AllNetworkGetAddress.ts +19 -21
- package/src/api/aptos/AptosGetAddress.ts +1 -1
- package/src/api/aptos/AptosGetPublicKey.ts +1 -1
- package/src/api/aptos/AptosSignMessage.ts +1 -1
- package/src/api/aptos/AptosSignTransaction.ts +1 -1
- package/src/api/benfen/BenfenGetAddress.ts +1 -1
- package/src/api/benfen/BenfenGetPublicKey.ts +1 -1
- package/src/api/benfen/BenfenSignMessage.ts +1 -1
- package/src/api/benfen/BenfenSignTransaction.ts +1 -1
- package/src/api/btc/BTCGetAddress.ts +1 -1
- package/src/api/btc/BTCGetPublicKey.ts +1 -1
- package/src/api/btc/BTCSignMessage.ts +1 -1
- package/src/api/btc/BTCSignPsbt.ts +1 -1
- package/src/api/btc/BTCSignTransaction.ts +1 -1
- package/src/api/btc/BTCVerifyMessage.ts +1 -1
- package/src/api/cardano/CardanoGetAddress.ts +1 -1
- package/src/api/cardano/CardanoGetPublicKey.ts +1 -1
- package/src/api/cardano/CardanoSignMessage.ts +1 -1
- package/src/api/cardano/CardanoSignTransaction.ts +1 -1
- package/src/api/conflux/ConfluxGetAddress.ts +1 -1
- package/src/api/conflux/ConfluxSignMessage.ts +1 -1
- package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -1
- package/src/api/conflux/ConfluxSignTransaction.ts +1 -1
- package/src/api/cosmos/CosmosGetAddress.ts +1 -1
- package/src/api/cosmos/CosmosGetPublicKey.ts +1 -1
- package/src/api/cosmos/CosmosSignTransaction.ts +1 -1
- package/src/api/device/DeviceUnlock.ts +26 -0
- package/src/api/device/DeviceUpdateBootloader.ts +1 -1
- package/src/api/dynex/DnxGetAddress.ts +1 -1
- package/src/api/dynex/DnxSignTransaction.ts +1 -1
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +1 -1
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/filecoin/FilecoinGetAddress.ts +1 -1
- package/src/api/filecoin/FilecoinSignTransaction.ts +1 -1
- package/src/api/index.ts +1 -0
- package/src/api/kaspa/KaspaGetAddress.ts +1 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +1 -1
- package/src/api/lightning/LnurlAuth.ts +1 -1
- package/src/api/near/NearGetAddress.ts +1 -1
- package/src/api/near/NearSignTransaction.ts +1 -1
- package/src/api/nem/NEMGetAddress.ts +1 -1
- package/src/api/nem/NEMSignTransaction.ts +1 -1
- package/src/api/neo/NeoGetAddress.ts +1 -1
- package/src/api/neo/NeoSignTransaction.ts +1 -1
- package/src/api/nervos/NervosGetAddress.ts +1 -1
- package/src/api/nervos/NervosSignTransaction.ts +1 -1
- package/src/api/nexa/NexaGetAddress.ts +1 -1
- package/src/api/nostr/NostrDecryptMessage.ts +1 -1
- package/src/api/nostr/NostrEncryptMessage.ts +1 -1
- package/src/api/nostr/NostrGetPublicKey.ts +1 -1
- package/src/api/nostr/NostrSignEvent.ts +1 -1
- package/src/api/nostr/NostrSignSchnorr.ts +1 -1
- package/src/api/polkadot/PolkadotGetAddress.ts +1 -1
- package/src/api/polkadot/PolkadotSignTransaction.ts +1 -1
- package/src/api/scdo/ScdoGetAddress.ts +1 -1
- package/src/api/scdo/ScdoSignMessage.ts +1 -1
- package/src/api/scdo/ScdoSignTransaction.ts +1 -1
- package/src/api/solana/SolGetAddress.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 +1 -1
- package/src/api/starcoin/StarcoinGetAddress.ts +1 -1
- package/src/api/starcoin/StarcoinGetPublicKey.ts +1 -1
- package/src/api/starcoin/StarcoinSignMessage.ts +1 -1
- package/src/api/starcoin/StarcoinSignTransaction.ts +1 -1
- package/src/api/starcoin/StarcoinVerifyMessage.ts +1 -1
- package/src/api/stellar/StellarGetAddress.ts +1 -1
- package/src/api/stellar/StellarSignTransaction.ts +1 -1
- 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/test/TestInitializeDeviceDuration.ts +3 -3
- 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/TronGetAddress.ts +1 -1
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/tron/TronSignTransaction.ts +1 -1
- package/src/api/xrp/XrpGetAddress.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +13 -8
- package/src/data/messages/messages.json +57 -2
- package/src/data-manager/DataManager.ts +1 -1
- package/src/data-manager/TransportManager.ts +0 -3
- package/src/device/Device.ts +77 -9
- package/src/device/DeviceCommands.ts +15 -4
- package/src/events/device.ts +4 -0
- package/src/events/ui-request.ts +3 -2
- package/src/events/ui-response.ts +1 -0
- package/src/inject.ts +2 -0
- package/src/types/api/deviceUnlock.ts +4 -0
- package/src/types/api/index.ts +2 -0
- package/src/types/settings.ts +1 -9
- package/src/utils/deviceFeaturesUtils.ts +71 -7
- package/src/utils/logger.ts +0 -2
|
@@ -38,7 +38,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
38
38
|
checkPromise: Deferred<any> | null = null;
|
|
39
39
|
|
|
40
40
|
init() {
|
|
41
|
-
this.
|
|
41
|
+
this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
|
|
42
42
|
this.requireDeviceMode = [];
|
|
43
43
|
this.useDevicePassphraseState = false;
|
|
44
44
|
this.skipForceUpdateCheck = true;
|
package/src/api/GetFeatures.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { BaseMethod } from './BaseMethod';
|
|
|
4
4
|
|
|
5
5
|
export default class GetFeatures extends BaseMethod {
|
|
6
6
|
init() {
|
|
7
|
-
this.
|
|
8
|
-
...this.
|
|
9
|
-
UI_REQUEST.
|
|
7
|
+
this.allowDeviceMode = [
|
|
8
|
+
...this.allowDeviceMode,
|
|
9
|
+
UI_REQUEST.NOT_INITIALIZE,
|
|
10
10
|
UI_REQUEST.BOOTLOADER,
|
|
11
11
|
];
|
|
12
12
|
this.useDevicePassphraseState = false;
|
|
@@ -5,9 +5,9 @@ import { BaseMethod } from './BaseMethod';
|
|
|
5
5
|
|
|
6
6
|
export default class GetOnekeyFeatures extends BaseMethod {
|
|
7
7
|
init() {
|
|
8
|
-
this.
|
|
9
|
-
...this.
|
|
10
|
-
UI_REQUEST.
|
|
8
|
+
this.allowDeviceMode = [
|
|
9
|
+
...this.allowDeviceMode,
|
|
10
|
+
UI_REQUEST.NOT_INITIALIZE,
|
|
11
11
|
UI_REQUEST.BOOTLOADER,
|
|
12
12
|
];
|
|
13
13
|
this.useDevicePassphraseState = false;
|
|
@@ -5,7 +5,7 @@ import { BaseMethod } from './BaseMethod';
|
|
|
5
5
|
|
|
6
6
|
export default class GetPassphraseState extends BaseMethod {
|
|
7
7
|
init() {
|
|
8
|
-
this.
|
|
8
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
9
9
|
this.useDevicePassphraseState = false;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -13,15 +13,31 @@ export default class GetPassphraseState extends BaseMethod {
|
|
|
13
13
|
if (!this.device.features)
|
|
14
14
|
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed));
|
|
15
15
|
|
|
16
|
-
const passphraseState = await getPassphraseStateWithRefreshDeviceInfo(
|
|
16
|
+
const { passphraseState, newSession } = await getPassphraseStateWithRefreshDeviceInfo(
|
|
17
|
+
this.device
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
console.log('=====>>>>>> GetPassphraseState run passphraseState: ', passphraseState);
|
|
21
|
+
console.log('=====>>>>>> GetPassphraseState run newSession: ', newSession);
|
|
22
|
+
console.log(
|
|
23
|
+
'=====>>>>>> GetPassphraseState run features: ',
|
|
24
|
+
this.device.features.passphrase_protection
|
|
25
|
+
);
|
|
26
|
+
|
|
17
27
|
const { features } = this.device;
|
|
18
28
|
|
|
29
|
+
// refresh device info
|
|
19
30
|
if (features && features.passphrase_protection === true) {
|
|
20
|
-
if (
|
|
21
|
-
|
|
31
|
+
if (!newSession) {
|
|
32
|
+
console.log('=====>>>>>> GetPassphraseState run tryFixInternalState', newSession);
|
|
33
|
+
if (passphraseState && features.device_id) {
|
|
34
|
+
this.device.tryFixInternalState(passphraseState, features.device_id, features.session_id);
|
|
35
|
+
}
|
|
22
36
|
}
|
|
37
|
+
|
|
23
38
|
return Promise.resolve(passphraseState);
|
|
24
39
|
}
|
|
40
|
+
|
|
25
41
|
return Promise.resolve(undefined);
|
|
26
42
|
}
|
|
27
43
|
}
|
|
@@ -10,7 +10,7 @@ export default class AlephiumGetAddress extends BaseMethod<HardwareAlephiumGetAd
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -8,7 +8,7 @@ import { stripHexPrefix } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class AlephiumSignMessage extends BaseMethod<HardwareAlephiumSignMessage> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
// check payload
|
|
14
14
|
validateParams(this.payload, [
|
|
@@ -15,7 +15,7 @@ import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
|
15
15
|
export default class AlephiumSignTransaction extends BaseMethod<HardwareAlephiumSignTx> {
|
|
16
16
|
init() {
|
|
17
17
|
this.checkDeviceId = true;
|
|
18
|
-
this.
|
|
18
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
19
19
|
|
|
20
20
|
// check payload
|
|
21
21
|
validateParams(this.payload, [
|
|
@@ -10,7 +10,7 @@ export default class AlgoGetAddress extends BaseMethod<HardwareAlgoGetAddress[]>
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -10,7 +10,7 @@ export default class AlgoSignTransaction extends BaseMethod<HardwareAlgorandSign
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
14
14
|
|
|
15
15
|
// check payload
|
|
16
16
|
validateParams(this.payload, [
|
|
@@ -236,6 +236,7 @@ type MethodParams = {
|
|
|
236
236
|
methodName: keyof CoreApi;
|
|
237
237
|
params: Parameters<CoreApi[keyof CoreApi]>[0];
|
|
238
238
|
_originRequestParams: AllNetworkAddressParams;
|
|
239
|
+
_originalIndex: number;
|
|
239
240
|
};
|
|
240
241
|
|
|
241
242
|
export default class AllNetworkGetAddress extends BaseMethod<
|
|
@@ -248,7 +249,7 @@ export default class AllNetworkGetAddress extends BaseMethod<
|
|
|
248
249
|
> {
|
|
249
250
|
init() {
|
|
250
251
|
this.checkDeviceId = true;
|
|
251
|
-
this.
|
|
252
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
252
253
|
|
|
253
254
|
// check payload
|
|
254
255
|
validateParams(this.payload, [{ name: 'bundle', type: 'array' }]);
|
|
@@ -267,9 +268,11 @@ export default class AllNetworkGetAddress extends BaseMethod<
|
|
|
267
268
|
generateMethodName({
|
|
268
269
|
network,
|
|
269
270
|
payload,
|
|
271
|
+
originalIndex,
|
|
270
272
|
}: {
|
|
271
273
|
network: INetwork;
|
|
272
274
|
payload: AllNetworkAddressParams;
|
|
275
|
+
originalIndex: number;
|
|
273
276
|
}): MethodParams {
|
|
274
277
|
const { name: networkName, coin } = networkAliases[network] || {
|
|
275
278
|
name: network,
|
|
@@ -287,6 +290,7 @@ export default class AllNetworkGetAddress extends BaseMethod<
|
|
|
287
290
|
originPayload: payload,
|
|
288
291
|
},
|
|
289
292
|
_originRequestParams: payload,
|
|
293
|
+
_originalIndex: originalIndex,
|
|
290
294
|
};
|
|
291
295
|
}
|
|
292
296
|
|
|
@@ -355,11 +359,12 @@ export default class AllNetworkGetAddress extends BaseMethod<
|
|
|
355
359
|
const responses: AllNetworkAddress[] = [];
|
|
356
360
|
const resultMap: Record<string, AllNetworkAddress> = {};
|
|
357
361
|
const { bundle } = this.payload as AllNetworkGetAddressParams;
|
|
358
|
-
const
|
|
359
|
-
.map(param =>
|
|
362
|
+
const methodGroups = bundle
|
|
363
|
+
.map((param, index) =>
|
|
360
364
|
this.generateMethodName({
|
|
361
365
|
network: param.network,
|
|
362
366
|
payload: param,
|
|
367
|
+
originalIndex: index,
|
|
363
368
|
})
|
|
364
369
|
)
|
|
365
370
|
.reduce((acc, cur) => {
|
|
@@ -370,27 +375,20 @@ export default class AllNetworkGetAddress extends BaseMethod<
|
|
|
370
375
|
return acc;
|
|
371
376
|
}, {} as Record<keyof CoreApi, MethodParams[]>);
|
|
372
377
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
for (let i = 0; i < methodParamsArray.length; i++) {
|
|
379
|
-
const methodParams = methodParamsArray[i];
|
|
380
|
-
const { methodName } = methodParams[0];
|
|
381
|
-
|
|
382
|
-
const params = {
|
|
383
|
-
bundle: methodParams.map(param => ({
|
|
378
|
+
let i = 0;
|
|
379
|
+
for (const [methodName, params] of Object.entries(methodGroups)) {
|
|
380
|
+
const methodParams = {
|
|
381
|
+
bundle: params.map(param => ({
|
|
384
382
|
...param.params,
|
|
385
383
|
})),
|
|
386
384
|
};
|
|
387
385
|
|
|
388
386
|
// call method
|
|
389
|
-
const response = await this.callMethod(methodName,
|
|
387
|
+
const response = await this.callMethod(methodName as keyof CoreApi, methodParams);
|
|
390
388
|
|
|
391
|
-
for (let i = 0; i <
|
|
392
|
-
const { _originRequestParams } =
|
|
393
|
-
const responseKey =
|
|
389
|
+
for (let i = 0; i < params.length; i++) {
|
|
390
|
+
const { _originRequestParams, _originalIndex } = params[i];
|
|
391
|
+
const responseKey = `${_originalIndex}`;
|
|
394
392
|
resultMap[responseKey] = {
|
|
395
393
|
..._originRequestParams,
|
|
396
394
|
...response[i],
|
|
@@ -401,11 +399,11 @@ export default class AllNetworkGetAddress extends BaseMethod<
|
|
|
401
399
|
const progress = Math.round(((i + 1) / this.payload.bundle.length) * 100);
|
|
402
400
|
this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, { progress }));
|
|
403
401
|
}
|
|
402
|
+
i++;
|
|
404
403
|
}
|
|
405
404
|
|
|
406
|
-
for (
|
|
407
|
-
|
|
408
|
-
responses.push(resultMap[responseKey]);
|
|
405
|
+
for (let i = 0; i < bundle.length; i++) {
|
|
406
|
+
responses.push(resultMap[i]);
|
|
409
407
|
}
|
|
410
408
|
|
|
411
409
|
return Promise.resolve(responses);
|
|
@@ -18,7 +18,7 @@ export default class AptosGetAddress extends BaseMethod<HardwareAptosGetAddress[
|
|
|
18
18
|
|
|
19
19
|
init() {
|
|
20
20
|
this.checkDeviceId = true;
|
|
21
|
-
this.
|
|
21
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
22
22
|
|
|
23
23
|
this.hasBundle = !!this.payload?.bundle;
|
|
24
24
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -10,7 +10,7 @@ export default class AptosGetPublicKey extends BaseMethod<any> {
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -8,7 +8,7 @@ import { AptosMessageSignature, AptosSignMessageParams } from '../../types';
|
|
|
8
8
|
export default class AptosSignMessage extends BaseMethod<HardwareAptosSignMessage> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
// check payload
|
|
14
14
|
validateParams(this.payload, [
|
|
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class AptosSignTransaction extends BaseMethod<HardwareAptosSignTx> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
// check payload
|
|
14
14
|
validateParams(this.payload, [
|
|
@@ -18,7 +18,7 @@ export default class BenfenGetAddress extends BaseMethod<HardwareBenfenGetAddres
|
|
|
18
18
|
|
|
19
19
|
init() {
|
|
20
20
|
this.checkDeviceId = true;
|
|
21
|
-
this.
|
|
21
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
22
22
|
|
|
23
23
|
this.hasBundle = !!this.payload?.bundle;
|
|
24
24
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -12,7 +12,7 @@ export default class BenfenGetPublicKey extends BaseMethod<any> {
|
|
|
12
12
|
|
|
13
13
|
init() {
|
|
14
14
|
this.checkDeviceId = true;
|
|
15
|
-
this.
|
|
15
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
16
16
|
|
|
17
17
|
this.hasBundle = !!this.payload?.bundle;
|
|
18
18
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -8,7 +8,7 @@ import { stripHexPrefix } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class BenfenSignMessage extends BaseMethod<HardwareBenfenSignMessage> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
validateParams(this.payload, [
|
|
14
14
|
{ name: 'path', required: true },
|
|
@@ -11,7 +11,7 @@ import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
|
11
11
|
export default class BenfenSignTransaction extends BaseMethod<BenfenSignTx> {
|
|
12
12
|
init() {
|
|
13
13
|
this.checkDeviceId = true;
|
|
14
|
-
this.
|
|
14
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
15
15
|
|
|
16
16
|
validateParams(this.payload, [
|
|
17
17
|
{ name: 'path', required: true },
|
|
@@ -12,7 +12,7 @@ export default class BTCGetAddress extends BaseMethod<GetAddress[]> {
|
|
|
12
12
|
|
|
13
13
|
init() {
|
|
14
14
|
this.checkDeviceId = true;
|
|
15
|
-
this.
|
|
15
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
16
16
|
|
|
17
17
|
this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
|
|
18
18
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -15,7 +15,7 @@ export default class BTCGetPublicKey extends BaseMethod<GetPublicKey[]> {
|
|
|
15
15
|
|
|
16
16
|
init() {
|
|
17
17
|
this.checkDeviceId = true;
|
|
18
|
-
this.
|
|
18
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
19
19
|
|
|
20
20
|
this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
|
|
21
21
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -10,7 +10,7 @@ import { getBitcoinForkVersionRange } from './helpers/versionLimit';
|
|
|
10
10
|
export default class BTCSignMessage extends BaseMethod<SignMessage> {
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
validateParams(this.payload, [
|
|
16
16
|
{ name: 'path', required: true },
|
|
@@ -10,7 +10,7 @@ import { getDeviceType } from '../../utils';
|
|
|
10
10
|
export default class BTCSignPsbt extends BaseMethod<SignPsbt> {
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
validateParams(this.payload, [
|
|
16
16
|
{ name: 'psbt', type: 'hexString', required: true },
|
|
@@ -27,7 +27,7 @@ type Params = {
|
|
|
27
27
|
export default class BTCSignTransaction extends BaseMethod<Params> {
|
|
28
28
|
init() {
|
|
29
29
|
this.checkDeviceId = true;
|
|
30
|
-
this.
|
|
30
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
31
31
|
|
|
32
32
|
validateParams(this.payload, [
|
|
33
33
|
{ name: 'coin', type: 'string', required: true },
|
|
@@ -10,7 +10,7 @@ import { getBitcoinForkVersionRange } from './helpers/versionLimit';
|
|
|
10
10
|
export default class BTCVerifyMessage extends BaseMethod<VerifyMessage> {
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
validateParams(this.payload, [
|
|
16
16
|
{ name: 'address', type: 'string', required: true },
|
|
@@ -18,7 +18,7 @@ export default class CardanoGetAddress extends BaseMethod<CardanoGetAddressParam
|
|
|
18
18
|
|
|
19
19
|
init() {
|
|
20
20
|
this.checkDeviceId = true;
|
|
21
|
-
this.
|
|
21
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
22
22
|
|
|
23
23
|
this.hasBundle = !!this.payload?.bundle;
|
|
24
24
|
this.isCheck = this.hasBundle
|
|
@@ -10,7 +10,7 @@ export default class CardanoGetPublicKey extends BaseMethod<CardanoPublicKeyPara
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -12,7 +12,7 @@ export default class CardanoSignMessage extends BaseMethod<CardanoSignMessagePar
|
|
|
12
12
|
|
|
13
13
|
init() {
|
|
14
14
|
this.checkDeviceId = true;
|
|
15
|
-
this.
|
|
15
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
16
16
|
|
|
17
17
|
const { payload } = this;
|
|
18
18
|
validateParams(payload, [
|
|
@@ -47,7 +47,7 @@ export default class CardanoSignTransaction extends BaseMethod<any> {
|
|
|
47
47
|
|
|
48
48
|
init() {
|
|
49
49
|
this.checkDeviceId = true;
|
|
50
|
-
this.
|
|
50
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
51
51
|
|
|
52
52
|
this.hasBundle = !!this.payload?.bundle;
|
|
53
53
|
|
|
@@ -9,7 +9,7 @@ export default class ConfluxGetAddress extends BaseMethod<HardwareConfluxGetAddr
|
|
|
9
9
|
hasBundle = false;
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
|
-
this.
|
|
12
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
13
13
|
|
|
14
14
|
this.hasBundle = !!this.payload?.bundle;
|
|
15
15
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -7,7 +7,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
7
7
|
|
|
8
8
|
export default class ConfluxSignMessage extends BaseMethod<HardwareConfluxSignMessage> {
|
|
9
9
|
init() {
|
|
10
|
-
this.
|
|
10
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
11
11
|
|
|
12
12
|
// check payload
|
|
13
13
|
validateParams(this.payload, [
|
|
@@ -7,7 +7,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
7
7
|
|
|
8
8
|
export default class ConfluxSignMessageCIP23 extends BaseMethod<HardwareConfluxSignMessageCIP23> {
|
|
9
9
|
init() {
|
|
10
|
-
this.
|
|
10
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
11
11
|
|
|
12
12
|
validateParams(this.payload, [
|
|
13
13
|
{ name: 'path', required: true },
|
|
@@ -20,7 +20,7 @@ export default class ConfluxSignTransaction extends BaseMethod {
|
|
|
20
20
|
formattedTx: ConfluxTransaction | undefined;
|
|
21
21
|
|
|
22
22
|
init() {
|
|
23
|
-
this.
|
|
23
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
24
24
|
|
|
25
25
|
validateParams(this.payload, [
|
|
26
26
|
{ name: 'path', required: true },
|
|
@@ -10,7 +10,7 @@ export default class CosmosGetAddress extends BaseMethod<HardwareCosmosGetAddres
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -10,7 +10,7 @@ export default class CosmosGetPublicKey extends BaseMethod<any> {
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -10,7 +10,7 @@ export default class CosmosSignTransaction extends BaseMethod<HardwareCosmosSign
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode];
|
|
14
14
|
|
|
15
15
|
// check payload
|
|
16
16
|
validateParams(this.payload, [
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LockDevice } from '@onekeyfe/hd-transport';
|
|
2
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
+
import { BaseMethod } from '../BaseMethod';
|
|
4
|
+
import { toHardened } from '../helpers/pathUtils';
|
|
5
|
+
|
|
6
|
+
export default class DeviceUnlock extends BaseMethod<LockDevice> {
|
|
7
|
+
init() {
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async run() {
|
|
12
|
+
const { type } = await this.device.commands.typedCall('GetAddress', 'Address', {
|
|
13
|
+
address_n: [toHardened(44), toHardened(1), toHardened(0), 0, 0],
|
|
14
|
+
coin_name: 'Testnet',
|
|
15
|
+
script_type: 'SPENDADDRESS',
|
|
16
|
+
show_display: false,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// @ts-expect-error
|
|
20
|
+
if (type === 'CallMethodError') {
|
|
21
|
+
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
22
|
+
}
|
|
23
|
+
const res = await this.device.commands.typedCall('GetFeatures', 'Features');
|
|
24
|
+
return Promise.resolve(res.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -16,7 +16,7 @@ export default class DeviceUpdateBootloader extends BaseMethod {
|
|
|
16
16
|
checkPromise: Deferred<any> | null = null;
|
|
17
17
|
|
|
18
18
|
init() {
|
|
19
|
-
this.
|
|
19
|
+
this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
|
|
20
20
|
this.requireDeviceMode = [];
|
|
21
21
|
this.useDevicePassphraseState = false;
|
|
22
22
|
this.skipForceUpdateCheck = true;
|
|
@@ -11,7 +11,7 @@ export default class DnxGetAddress extends BaseMethod<HardwareDnxGetAddress[]> {
|
|
|
11
11
|
|
|
12
12
|
init() {
|
|
13
13
|
this.checkDeviceId = true;
|
|
14
|
-
this.
|
|
14
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
15
15
|
|
|
16
16
|
this.hasBundle = !!this.payload?.bundle;
|
|
17
17
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -13,7 +13,7 @@ export default class DnxSignTransaction extends BaseMethod<DnxSignTx> {
|
|
|
13
13
|
|
|
14
14
|
init() {
|
|
15
15
|
this.checkDeviceId = true;
|
|
16
|
-
this.
|
|
16
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
17
17
|
|
|
18
18
|
const { payload } = this;
|
|
19
19
|
// init params
|
|
@@ -13,7 +13,7 @@ export default class EvmGetAddress extends BaseMethod<EthereumGetAddressOneKey[]
|
|
|
13
13
|
|
|
14
14
|
init() {
|
|
15
15
|
this.checkDeviceId = true;
|
|
16
|
-
this.
|
|
16
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
17
17
|
|
|
18
18
|
this.hasBundle = !!this.payload?.bundle;
|
|
19
19
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|
|
@@ -17,7 +17,7 @@ export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKeyOneK
|
|
|
17
17
|
|
|
18
18
|
init() {
|
|
19
19
|
this.checkDeviceId = true;
|
|
20
|
-
this.
|
|
20
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
21
21
|
|
|
22
22
|
this.hasBundle = !!this.payload?.bundle;
|
|
23
23
|
this.useBatch = this.payload?.bundle?.every(
|
|
@@ -11,7 +11,7 @@ import signMessageLegacyV1 from './legacyV1/signMessage';
|
|
|
11
11
|
export default class EVMSignMessage extends BaseMethod<EthereumSignMessageOneKey> {
|
|
12
12
|
init() {
|
|
13
13
|
this.checkDeviceId = true;
|
|
14
|
-
this.
|
|
14
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
15
15
|
|
|
16
16
|
// check payload
|
|
17
17
|
validateParams(this.payload, [
|
|
@@ -8,7 +8,7 @@ import { formatAnyHex } from '../helpers/hexUtils';
|
|
|
8
8
|
export default class EVMSignMessageEIP712 extends BaseMethod<EthereumSignMessageEIP712> {
|
|
9
9
|
init() {
|
|
10
10
|
this.checkDeviceId = true;
|
|
11
|
-
this.
|
|
11
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
12
12
|
|
|
13
13
|
validateParams(this.payload, [
|
|
14
14
|
{ name: 'path', required: true },
|
|
@@ -18,7 +18,7 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
18
18
|
|
|
19
19
|
init() {
|
|
20
20
|
this.checkDeviceId = true;
|
|
21
|
-
this.
|
|
21
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
22
22
|
|
|
23
23
|
validateParams(this.payload, [
|
|
24
24
|
{ name: 'path', required: true },
|
|
@@ -39,7 +39,7 @@ export type EVMSignTypedDataParams = {
|
|
|
39
39
|
export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams> {
|
|
40
40
|
init() {
|
|
41
41
|
this.checkDeviceId = true;
|
|
42
|
-
this.
|
|
42
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
43
43
|
|
|
44
44
|
validateParams(this.payload, [
|
|
45
45
|
{ name: 'path', required: true },
|
|
@@ -10,7 +10,7 @@ import verifyMessage from './latest/verifyMessage';
|
|
|
10
10
|
export default class EVMSignMessage extends BaseMethod<EthereumVerifyMessageOneKey> {
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
validateParams(this.payload, [
|
|
16
16
|
{ name: 'address', type: 'string', required: true },
|
|
@@ -10,7 +10,7 @@ export default class FilecoinGetAddress extends BaseMethod<HardwareFilecoinGetAd
|
|
|
10
10
|
|
|
11
11
|
init() {
|
|
12
12
|
this.checkDeviceId = true;
|
|
13
|
-
this.
|
|
13
|
+
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
14
14
|
|
|
15
15
|
this.hasBundle = !!this.payload?.bundle;
|
|
16
16
|
const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
|