Skip to content

Commit 71073f7

Browse files
authored
OK-19750, OK-19769: add params for scan qrcode validate & add connectId for Bluetooth connect (#2943)
* fix: enable imported account for Cardano * feat: add usedfor params for scan qrcode * fix: add connectId for bluetooth connect * feat: skipHeavyChains
1 parent e8f9d9e commit 71073f7

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

packages/engine/src/validators.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { isString } from 'lodash';
66
import type { Network } from '@onekeyhq/kit/src/store/typings';
77
import { backgroundMethod } from '@onekeyhq/shared/src/background/backgroundDecorators';
88
import {
9-
IMPL_ADA,
109
IMPL_COSMOS,
1110
IMPL_DOT,
1211
IMPL_XMR,
@@ -28,7 +27,7 @@ const FEE_LIMIT_HIGH_VALUE_TIMES = 20;
2827
const FEE_PRICE_HIGH_VALUE_TIMES = 4;
2928

3029
const FORK_CHAIN_ADDRESS_NOT_DIFFERENT = [IMPL_COSMOS, IMPL_DOT];
31-
const WEBVIEW_BACKED_CHAIN = platformEnv.isNative ? [IMPL_ADA, IMPL_XMR] : [];
30+
const WEBVIEW_BACKED_CHAIN = platformEnv.isNative ? [IMPL_XMR] : [];
3231

3332
class Validators {
3433
private _dbApi: DBAPI;
@@ -106,6 +105,7 @@ class Validators {
106105
input: string,
107106
forCategories: Array<UserInputCategory> = [],
108107
returnEarly = false,
108+
skipHeavyChains = false,
109109
): Promise<Array<UserInputCheckResult>> {
110110
const ret = [];
111111
const filterCategories =
@@ -139,7 +139,7 @@ class Validators {
139139
for (const [impl, networks] of Object.entries(
140140
await this.engine.listEnabledNetworksGroupedByVault(),
141141
)) {
142-
if (WEBVIEW_BACKED_CHAIN.includes(impl)) {
142+
if (skipHeavyChains && WEBVIEW_BACKED_CHAIN.includes(impl)) {
143143
// skip webview backed chain
144144
// eslint-disable-next-line no-continue
145145
continue;
@@ -181,15 +181,18 @@ class Validators {
181181
input,
182182
onlyFor,
183183
returnEarly,
184+
skipHeavyChains,
184185
}: {
185186
input: string;
186187
onlyFor?: UserInputCategory;
187188
returnEarly?: boolean;
189+
skipHeavyChains?: boolean;
188190
}) {
189191
return this.validateUserInput(
190192
input,
191193
onlyFor !== undefined ? [onlyFor] : [],
192194
returnEarly,
195+
skipHeavyChains,
193196
);
194197
}
195198

packages/kit-bg/src/services/ServiceHardware.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,15 @@ class ServiceHardware extends ServiceBase {
376376
const version = settings.deviceUpdates?.[connectId][firmwareType]?.version;
377377

378378
try {
379-
const response = await hardwareSDK.firmwareUpdateV2(undefined, {
380-
updateType: firmwareType,
381-
forcedUpdateRes,
382-
version,
383-
platform: platformEnv.symbol ?? 'web',
384-
});
379+
const response = await hardwareSDK.firmwareUpdateV2(
380+
platformEnv.isNative ? connectId : undefined,
381+
{
382+
updateType: firmwareType,
383+
forcedUpdateRes,
384+
version,
385+
platform: platformEnv.symbol ?? 'web',
386+
},
387+
);
385388

386389
// update bootloader
387390
if (
@@ -850,7 +853,9 @@ class ServiceHardware extends ServiceBase {
850853
) {
851854
const hardwareSDK = await this.getSDKInstance();
852855
return hardwareSDK
853-
?.checkBootloaderRelease(undefined, { willUpdateFirmwareVersion })
856+
?.checkBootloaderRelease(platformEnv.isNative ? connectId : undefined, {
857+
willUpdateFirmwareVersion,
858+
})
854859
.then((response) => {
855860
if (!response.success) {
856861
return Promise.reject(
@@ -862,7 +867,7 @@ class ServiceHardware extends ServiceBase {
862867
}
863868

864869
@backgroundMethod()
865-
async updateBootloaderForClassicAndMini() {
870+
async updateBootloaderForClassicAndMini(connectId: string) {
866871
const { dispatch } = this.backgroundApi;
867872
dispatch(setUpdateFirmwareStep(''));
868873
const hardwareSDK = await this.getSDKInstance();
@@ -871,11 +876,14 @@ class ServiceHardware extends ServiceBase {
871876
};
872877
hardwareSDK.on('ui-firmware-tip', listener);
873878
try {
874-
const response = await hardwareSDK.firmwareUpdateV2(undefined, {
875-
updateType: 'firmware',
876-
platform: platformEnv.symbol ?? 'web',
877-
isUpdateBootloader: true,
878-
});
879+
const response = await hardwareSDK.firmwareUpdateV2(
880+
platformEnv.isNative ? connectId : undefined,
881+
{
882+
updateType: 'firmware',
883+
platform: platformEnv.symbol ?? 'web',
884+
isUpdateBootloader: true,
885+
},
886+
);
879887
return response;
880888
} finally {
881889
hardwareSDK.off('ui-firmware-tip', listener);

packages/kit/src/views/Hardware/UpdateFirmware/UpdatingBootloader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ const UpdatingBootloader: FC = () => {
386386
return;
387387
}
388388
serviceHardware
389-
.updateBootloaderForClassicAndMini()
389+
.updateBootloaderForClassicAndMini(connectId)
390390
.then(async (res) => {
391391
if (res.success) {
392392
engine.getWalletByDeviceId(device?.id ?? '').then((wallet) => {

packages/kit/src/views/ScanQrcode/ScanQrcodeResult.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const ScanQrcodeResult: FC = () => {
9595
.validateCreateInput({
9696
input: data,
9797
returnEarly: true,
98+
skipHeavyChains: true,
9899
})
99100
.then(([result]) => {
100101
if (result) {

0 commit comments

Comments
 (0)