Skip to content

Commit 9727770

Browse files
committed
chore: fix basic error
1 parent f24677c commit 9727770

File tree

9 files changed

+99
-80
lines changed

9 files changed

+99
-80
lines changed

packages/connect-examples/expo-example/locale/en-US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"action__update_restart": "Restart installation update",
2626

2727
"action__start_test": "Start Test",
28-
"action__start_error_test": "Start testing failed cases",
28+
"action__start_error_test": "Testing failed cases",
2929
"action__stop_test": "Stop Test",
3030

3131
"tip__update_ready": "There are new versions that can be updated",

packages/connect-examples/expo-example/locale/zh-CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"action__update_restart": "重启并安装更新",
2626

2727
"action__start_test": "开始测试",
28-
"action__start_error_test": "开始测试失败用例",
28+
"action__start_error_test": "测试失败用例",
2929
"action__stop_test": "停止测试",
3030

3131
"tip__update_ready": "检测到新的版本可以更新,点击进行安装",

packages/connect-examples/expo-example/src/components/BaseTestRunner/useRunnerTest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,10 @@ export function useRunnerTest<T>(config: RunnerConfig<T>) {
279279
}
280280
}
281281
endTestRunner();
282-
} catch (e) {
283-
console.log('error', e);
282+
} catch (e: any) {
284283
stopTest();
284+
console.log('error', e);
285+
alert(e.message);
285286
}
286287
}, [
287288
setRunnerLogs,

packages/connect-examples/expo-example/src/components/Playground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface TestExpect {
1616
requestPin?: boolean;
1717
requestButton?: boolean;
1818
unknownMessage?: boolean;
19-
error?: boolean;
19+
error?: boolean | number;
2020
}
2121

2222
export interface TestModalExpect {

packages/connect-examples/expo-example/src/data/basic.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ const api: PlaygroundProps[] = [
4545
success: true,
4646
},
4747
},
48+
classic: {
49+
normal: {
50+
unknownMessage: true,
51+
},
52+
bootloader: {
53+
unknownMessage: true,
54+
},
55+
},
56+
classic1s: {
57+
normal: {
58+
unknownMessage: true,
59+
},
60+
bootloader: {
61+
unknownMessage: true,
62+
},
63+
},
64+
mini: {
65+
normal: {
66+
unknownMessage: true,
67+
},
68+
bootloader: {
69+
unknownMessage: true,
70+
},
71+
},
4872
},
4973
},
5074
{

packages/connect-examples/expo-example/src/data/device.ts

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
12
import { type PlaygroundProps } from '../components/Playground';
23

34
const api: PlaygroundProps[] = [
@@ -113,6 +114,9 @@ const api: PlaygroundProps[] = [
113114
normal: {
114115
requestPin: true,
115116
},
117+
bootloader: {
118+
unknownMessage: true,
119+
},
116120
},
117121
},
118122
},
@@ -121,98 +125,48 @@ const api: PlaygroundProps[] = [
121125
value: {
122126
usePassphrase: true,
123127
},
124-
expect: {
125-
common: {
126-
normal: {
127-
skip: true,
128-
},
129-
bootloader: {
130-
skip: true,
131-
},
132-
},
133-
},
134128
},
135129
{
136130
title: 'Disable Passphrase',
137131
value: {
138132
usePassphrase: false,
139133
},
140-
expect: {
141-
common: {
142-
normal: {
143-
skip: true,
144-
},
145-
bootloader: {
146-
skip: true,
147-
},
148-
},
149-
},
150134
},
151135
{
152136
title: 'Set PassphraseAlwaysOnDevice',
153137
value: {
154138
passphraseAlwaysOnDevice: true,
155139
},
156-
expect: {
157-
common: {
158-
normal: {
159-
skip: true,
160-
},
161-
bootloader: {
162-
skip: true,
163-
},
164-
},
165-
},
166140
},
167141
{
168142
title: 'Set English language',
169143
value: {
170144
language: 'en_UK',
171145
},
172-
expect: {
173-
common: {
174-
normal: {
175-
skip: true,
176-
},
177-
bootloader: {
178-
skip: true,
179-
},
180-
},
181-
},
182146
},
183147
{
184148
title: 'Set Chinese language',
185149
value: {
186150
language: 'zh_CN',
187151
},
188-
expect: {
189-
common: {
190-
normal: {
191-
skip: true,
192-
},
193-
bootloader: {
194-
skip: true,
195-
},
196-
},
197-
},
198152
},
199153
{
200154
title: 'Set safetyChecks',
201155
value: {
202156
safetyChecks: 0,
203157
},
204-
expect: {
205-
common: {
206-
normal: {
207-
skip: true,
208-
},
209-
bootloader: {
210-
skip: true,
211-
},
212-
},
213-
},
214158
},
215159
],
160+
expect: {
161+
common: {
162+
normal: {
163+
skip: true,
164+
},
165+
bootloader: {
166+
skip: true,
167+
},
168+
},
169+
},
216170
},
217171
{
218172
method: 'deviceFlags',
@@ -536,16 +490,25 @@ const api: PlaygroundProps[] = [
536490
normal: {
537491
success: true,
538492
},
493+
bootloader: {
494+
success: true,
495+
},
539496
},
540497
classic: {
541498
normal: {
542499
success: true,
543500
},
501+
bootloader: {
502+
success: true,
503+
},
544504
},
545505
classic1s: {
546506
normal: {
547507
success: true,
548508
},
509+
bootloader: {
510+
success: true,
511+
},
549512
},
550513
},
551514
},
@@ -572,18 +535,28 @@ const api: PlaygroundProps[] = [
572535
expect: {
573536
mini: {
574537
normal: {
575-
requestButton: true,
538+
// You need to manually enter boot
539+
error: HardwareErrorCode.FirmwareUpdateManuallyEnterBoot,
540+
},
541+
bootloader: {
542+
skip: true,
576543
},
577544
},
578545
classic: {
579546
normal: {
580547
requestButton: true,
581548
},
549+
bootloader: {
550+
skip: true,
551+
},
582552
},
583553
classic1s: {
584554
normal: {
585555
requestButton: true,
586556
},
557+
bootloader: {
558+
skip: true,
559+
},
587560
},
588561
},
589562
},

packages/connect-examples/expo-example/src/testTools/securityCheckTest/apiExportTest/TestApiExport.tsx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CoreMessage, UI_EVENT, UI_REQUEST, UI_RESPONSE, getDeviceType } from '@
33
import { Picker } from '@react-native-picker/picker';
44
import { useIntl } from 'react-intl';
55
import { Stack, Text, View } from 'tamagui';
6+
import { number } from 'bitcoinjs-lib/src/script';
67
import { TestRunnerView } from '../../../components/BaseTestRunner/TestRunnerView';
78
import { useRunnerTest } from '../../../components/BaseTestRunner/useRunnerTest';
89
import { ApiExportTestCase } from './types';
@@ -142,7 +143,11 @@ function ResultView({ item }: ResultViewProps) {
142143
} else if (item?.result?.unknownMessage) {
143144
result = 'UnknownMessage or Device Not Support';
144145
} else if (item?.result?.error) {
145-
result = 'Call Error';
146+
if (typeof item?.result?.error === 'number') {
147+
result = `Error Code: ${item?.result?.error}`;
148+
} else {
149+
result = 'Call Error';
150+
}
146151
}
147152

148153
return (
@@ -316,19 +321,23 @@ function ExecuteView() {
316321

317322
currentRequestDeviceRef.current = deviceType;
318323

324+
// goto bootloader
325+
if (currentTestClass === 'bootloader' && !hasBootloaderMode) {
326+
await sdk.deviceUpdateReboot(connectId ?? '');
327+
await sleep(5 * 1000);
328+
}
329+
330+
if (currentTestClass === 'normal' && hasBootloaderMode) {
331+
return Promise.reject(new Error('重启设备到普通模式'));
332+
}
333+
319334
// lock device
320335
if (currentTestClass === 'normal' && !hasBootloaderMode && feature.unlocked === true) {
321336
await sdk.deviceLock(connectId ?? '', {
322337
retryCount: 1,
323338
});
324339
}
325340

326-
// goto bootloader
327-
if (currentTestClass === 'bootloader' && !hasBootloaderMode) {
328-
await sdk.deviceUpdateReboot(connectId ?? '');
329-
await sleep(5 * 1000);
330-
}
331-
332341
if (errorCaseRef.current?.length > 0) {
333342
const preErrorCase = errorCaseRef.current;
334343
errorCaseRef.current = [];
@@ -544,8 +553,14 @@ function ExecuteView() {
544553
verifyState = 'fail';
545554
error = res.payload?.error;
546555
addErrorCase(item);
547-
} else if (item.result.error && (res.payload?.code === 800 || res.success === false)) {
548-
verifyState = 'success';
556+
} else if (item.result.error) {
557+
if (typeof item.result.error === 'number') {
558+
if (res.payload?.code === item.result.error) {
559+
verifyState = 'success';
560+
}
561+
} else if (res.payload?.code === 800 || res.success === false) {
562+
verifyState = 'success';
563+
}
549564
} else if (item.result.success && res.success) {
550565
verifyState = 'success';
551566
} else if (
@@ -629,7 +644,13 @@ function ExecuteView() {
629644
type="number"
630645
onChange={setBootNextDelayMsState}
631646
/>
632-
<TestRunnerOptionButtons onStop={stopTest} onStart={beginTest} />
647+
<TestRunnerOptionButtons
648+
onStop={stopTest}
649+
onStart={() => {
650+
errorCaseRef.current = [];
651+
beginTest();
652+
}}
653+
/>
633654
<ExportReportView testScope={currentTestCaseType} testModel={currentTestClass} />
634655
<TestRunnerErrorButtons
635656
onStart={beginTest}

packages/core/src/inject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ export const createCoreApi = (
284284
call({ ...params, connectId, deviceId, method: 'cardanoGetPublicKey' }),
285285
cardanoSignTransaction: (connectId, deviceId, params) =>
286286
call({ ...params, connectId, deviceId, method: 'cardanoSignTransaction' }),
287-
// cardanoSignMessage: (connectId, deviceId, params) =>
288-
// call({ ...params, connectId, deviceId, method: 'cardanoSignMessage' }),
287+
cardanoSignMessage: (connectId, deviceId, params) =>
288+
call({ ...params, connectId, deviceId, method: 'cardanoSignMessage' }),
289289

290290
filecoinGetAddress: (connectId, deviceId, params) =>
291291
call({ ...params, connectId, deviceId, method: 'filecoinGetAddress' }),

packages/core/src/types/api/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ import { suiSignTransaction } from './suiSignTransaction';
106106
import { cardanoGetAddress } from './cardanoGetAddress';
107107
import { cardanoGetPublicKey } from './cardanoGetPublicKey';
108108
import { cardanoSignTransaction } from './cardanoSignTransaction';
109-
// import { cardanoSignMessage } from './cardanoSignMessage';
109+
import { cardanoSignMessage } from './cardanoSignMessage';
110110

111111
import { filecoinGetAddress } from './filecoinGetAddress';
112112
import { filecoinSignTransaction } from './filecoinSignTransaction';
@@ -405,7 +405,7 @@ export type CoreApi = {
405405
cardanoGetAddress: typeof cardanoGetAddress;
406406
cardanoGetPublicKey: typeof cardanoGetPublicKey;
407407
cardanoSignTransaction: typeof cardanoSignTransaction;
408-
// cardanoSignMessage: typeof cardanoSignMessage;
408+
cardanoSignMessage: typeof cardanoSignMessage;
409409

410410
/**
411411
* Filecoin function

0 commit comments

Comments
 (0)