Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/connect-examples/electron-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hardware-example",
"productName": "HardwareExample",
"executableName": "onekey-hardware-example",
"version": "1.1.22-alpha.2",
"version": "1.1.22-alpha.5",
"author": "OneKey",
"description": "End-to-end encrypted workspaces for teams",
"main": "dist/index.js",
Expand All @@ -22,7 +22,7 @@
"ts:check": "yarn tsc --noEmit"
},
"dependencies": {
"@onekeyfe/hd-transport-electron": "1.1.22-alpha.2",
"@onekeyfe/hd-transport-electron": "1.1.22-alpha.5",
"@stoprocent/noble": "2.3.4",
"debug": "4.3.4",
"electron-is-dev": "^3.0.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-example",
"version": "1.1.22-alpha.2",
"version": "1.1.22-alpha.5",
"scripts": {
"start": "cross-env CONNECT_SRC=https://localhost:8087/ yarn expo start --dev-client",
"android": "yarn expo run:android",
Expand All @@ -19,10 +19,10 @@
"@noble/ed25519": "^2.1.0",
"@noble/hashes": "^1.3.3",
"@noble/secp256k1": "^1.7.1",
"@onekeyfe/hd-ble-sdk": "1.1.22-alpha.2",
"@onekeyfe/hd-common-connect-sdk": "1.1.22-alpha.2",
"@onekeyfe/hd-core": "1.1.22-alpha.2",
"@onekeyfe/hd-web-sdk": "1.1.22-alpha.2",
"@onekeyfe/hd-ble-sdk": "1.1.22-alpha.5",
"@onekeyfe/hd-common-connect-sdk": "1.1.22-alpha.5",
"@onekeyfe/hd-core": "1.1.22-alpha.5",
"@onekeyfe/hd-web-sdk": "1.1.22-alpha.5",
"@onekeyfe/react-native-ble-utils": "^0.1.3",
"@polkadot/util-crypto": "13.1.1",
"@react-native-async-storage/async-storage": "1.21.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/connect-examples/expo-playground/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onekey-hardware-playground",
"version": "1.1.22-alpha.2",
"version": "1.1.22-alpha.5",
"private": true,
"sideEffects": [
"app/utils/shim.js",
Expand All @@ -17,9 +17,9 @@
},
"dependencies": {
"@noble/hashes": "^1.8.0",
"@onekeyfe/hd-common-connect-sdk": "1.1.22-alpha.2",
"@onekeyfe/hd-core": "1.1.22-alpha.2",
"@onekeyfe/hd-shared": "1.1.22-alpha.2",
"@onekeyfe/hd-common-connect-sdk": "1.1.22-alpha.5",
"@onekeyfe/hd-core": "1.1.22-alpha.5",
"@onekeyfe/hd-shared": "1.1.22-alpha.5",
"@radix-ui/react-checkbox": "^1.3.2",
"@radix-ui/react-dialog": "^1.1.14",
"@radix-ui/react-dropdown-menu": "^2.1.15",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-core",
"version": "1.1.22-alpha.2",
"version": "1.1.22-alpha.5",
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -25,8 +25,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "1.1.22-alpha.2",
"@onekeyfe/hd-transport": "1.1.22-alpha.2",
"@onekeyfe/hd-shared": "1.1.22-alpha.5",
"@onekeyfe/hd-transport": "1.1.22-alpha.5",
"axios": "1.12.2",
"bignumber.js": "^9.0.2",
"bytebuffer": "^5.0.1",
Expand Down
50 changes: 45 additions & 5 deletions packages/core/src/api/device/DeviceSettings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { ApplySettings } from '@onekeyfe/hd-transport';
import { HardwareErrorCode, TypedError } from '@onekeyfe/hd-shared';

import { BaseMethod } from '../BaseMethod';
import { validateParams } from '../helpers/paramsValidator';
import { LANGUAGE_LABELS } from '../../utils/deviceSettings';

import type { ApplySettings } from '@onekeyfe/hd-transport';

export default class DeviceSettings extends BaseMethod<ApplySettings> {
init() {
Expand All @@ -18,6 +22,9 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
{ name: 'passphraseAlwaysOnDevice', type: 'boolean' },
{ name: 'safetyChecks', type: 'number' },
{ name: 'experimentalFeatures', type: 'boolean' },
{ name: 'autoShutdownDelayMs', type: 'number' },
{ name: 'changeBrightness', type: 'boolean' },
{ name: 'hapticFeedback', type: 'boolean' },
]);

// init params
Expand All @@ -32,6 +39,11 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
passphrase_always_on_device: this.payload.passphraseAlwaysOnDevice,
safety_checks: this.payload.safetyChecks,
experimental_features: this.payload.experimentalFeatures,
auto_shutdown_delay_ms: this.payload.autoShutdownDelayMs,
...(this.payload.changeBrightness
? { change_brightness: this.payload.changeBrightness }
: undefined),
haptic_feedback: this.payload.hapticFeedback,
};
}

Expand All @@ -47,10 +59,38 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
}

async run() {
const res = await this.device.commands.typedCall('ApplySettings', 'Success', {
...this.params,
});
try {
const res = await this.device.commands.typedCall('ApplySettings', 'Success', {
...this.params,
});
return res.message;
} catch (error) {
if (error.message?.toLowerCase().includes('no setting provided')) {
return Promise.reject(
TypedError(HardwareErrorCode.DeviceSettingsNotProvided, error.message)
);
}
if (error.message?.includes('all support ISO_639-1 language keys include')) {
const supportedLanguages: string[] = error.message
?.replace('all support ISO_639-1 language keys include', '')
?.trim()
?.split(' ');

return Promise.resolve(res.message);
const errorMessage = supportedLanguages.reduce((acc, language) => {
const label = LANGUAGE_LABELS?.[language as keyof typeof LANGUAGE_LABELS];
if (label) {
acc.push(label);
}
return acc;
}, [] as string[]);

return Promise.reject(
TypedError(HardwareErrorCode.DeviceSettingsLanguageNotSupport, error.message, {
languages: errorMessage.join(', '),
})
);
}
throw error;
}
}
}
7 changes: 5 additions & 2 deletions packages/core/src/api/solana/SolSignTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { SolanaSignTx as HardwareSolanaSignTx } from '@onekeyfe/hd-transport';
import { UI_REQUEST } from '../../constants/ui-request';
import { serializedPath, validatePath } from '../helpers/pathUtils';
import { BaseMethod } from '../BaseMethod';
import { validateParams } from '../helpers/paramsValidator';
import { SolanaSignedTx, SolanaSignTransactionParams } from '../../types';
import { formatAnyHex } from '../helpers/hexUtils';

import type { SolanaSignTransactionParams, SolanaSignedTx } from '../../types';
import type { SolanaSignTx as HardwareSolanaSignTx } from '@onekeyfe/hd-transport';

export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[]> {
hasBundle = false;

Expand All @@ -27,11 +28,13 @@ export default class SolSignTransaction extends BaseMethod<HardwareSolanaSignTx[
validateParams(batch, [
{ name: 'path', required: true },
{ name: 'rawTx', type: 'hexString', required: true },
{ name: 'extraInfo', type: 'object' },
]);

this.params.push({
address_n: addressN,
raw_tx: formatAnyHex(batch.rawTx),
...(batch.extraInfo ? { extra_info: batch.extraInfo } : undefined),
});
});
}
Expand Down
61 changes: 61 additions & 0 deletions packages/core/src/data/messages/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6498,6 +6498,18 @@
"type": "uint32",
"id": 520
},
"brightness_prcent": {
"type": "uint32",
"id": 521
},
"haptic_feedback": {
"type": "bool",
"id": 522
},
"auto_shutdown_delay_ms": {
"type": "uint32",
"id": 523
},
"onekey_device_type": {
"type": "OneKeyDeviceType",
"id": 600
Expand Down Expand Up @@ -6894,6 +6906,18 @@
"fastpay_times": {
"type": "uint32",
"id": 106
},
"auto_shutdown_delay_ms": {
"type": "uint32",
"id": 500
},
"change_brightness": {
"type": "bool",
"id": 501
},
"haptic_feedback": {
"type": "bool",
"id": 502
}
},
"nested": {
Expand Down Expand Up @@ -9869,6 +9893,39 @@
}
}
},
"SolanaTxATADetails": {
"fields": {
"owner_address": {
"rule": "required",
"type": "string",
"id": 1
},
"program_id": {
"rule": "required",
"type": "string",
"id": 2
},
"mint_address": {
"rule": "required",
"type": "string",
"id": 3
},
"associated_token_address": {
"rule": "required",
"type": "string",
"id": 4
}
}
},
"SolanaTxExtraInfo": {
"fields": {
"ata_details": {
"rule": "repeated",
"type": "SolanaTxATADetails",
"id": 1
}
}
},
"SolanaSignTx": {
"fields": {
"address_n": {
Expand All @@ -9883,6 +9940,10 @@
"rule": "required",
"type": "bytes",
"id": 2
},
"extra_info": {
"type": "SolanaTxExtraInfo",
"id": 3
}
}
},
Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/data/messages/messages_legacy_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -5093,6 +5093,18 @@
"battery_level": {
"type": "uint32",
"id": 520
},
"brightness_prcent": {
"type": "uint32",
"id": 521
},
"haptic_feedback": {
"type": "bool",
"id": 522
},
"auto_shutdown_delay_ms": {
"type": "uint32",
"id": 523
}
},
"nested": {
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/types/api/deviceSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SafetyCheckLevel, Success } from '@onekeyfe/hd-transport';
import type { SafetyCheckLevel, Success } from '@onekeyfe/hd-transport';
import type { CommonParams, Response } from '../params';

export type DeviceSettingsParams = {
Expand All @@ -12,6 +12,9 @@ export type DeviceSettingsParams = {
passphraseAlwaysOnDevice?: boolean;
safetyChecks?: SafetyCheckLevel;
experimentalFeatures?: boolean;
autoShutdownDelayMs?: number;
changeBrightness?: boolean;
hapticFeedback?: boolean;
};

export declare function deviceSettings(
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/types/api/solSignTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { SolanaSignedTx as HardwareSolanaSignedTx } from '@onekeyfe/hd-transport';
import type {
SolanaSignedTx as HardwareSolanaSignedTx,
SolanaTxExtraInfo,
} from '@onekeyfe/hd-transport';
import type { CommonParams, Response } from '../params';

export type SolanaSignedTx = {
Expand All @@ -8,6 +11,7 @@ export type SolanaSignedTx = {
export type SolanaSignTransactionParams = {
path: string | number[];
rawTx?: string;
extraInfo?: SolanaTxExtraInfo;
};

export declare function solSignTransaction(
Expand Down
Loading
Loading