Skip to content

Commit

Permalink
disable BTC hardware support on mobile platforms OK-9087 OK-9581 (#830)
Browse files Browse the repository at this point in the history
* chore: disable BTC hardware support on mobile platforms

Fixes: OK-9581

* fix: filter networks for supported account types

Fixes: OK-9087
  • Loading branch information
taimanhui authored Jun 6, 2022
1 parent 8897f14 commit f83baff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/engine/src/vaults/impl/btc/settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import platformEnv from '@onekeyhq/shared/src/platformEnv';

import { IVaultSettings } from '../../types';

const settings: IVaultSettings = {
Expand All @@ -6,7 +8,7 @@ const settings: IVaultSettings = {
tokenEnabled: false,

importedAccountEnabled: true,
hardwareAccountEnabled: true,
hardwareAccountEnabled: !platformEnv.isNative,
watchingAccountEnabled: true,
};

Expand Down
31 changes: 27 additions & 4 deletions packages/kit/src/views/Account/AddNewAccount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,38 @@ const CreateAccount: FC<CreateAccountProps> = ({ onClose }) => {
'network',
activeNetworkId ?? (networks ?? [])?.[0]?.id,
);
const selectableNetworks = networks
.filter((network) => {
if (wallet?.type === 'hw') {
return network.settings.hardwareAccountEnabled;
}
if (wallet?.type === 'imported') {
return network.settings.importedAccountEnabled;
}
if (wallet?.type === 'watching') {
return network.settings.watchingAccountEnabled;
}
return true;
})
.map((network) => network.id);
const isSmallScreen = useIsVerticalLayout();

useEffect(() => {
const selectedNetwork =
networks?.find((n) => n.id === watchNetwork) ?? null;
const selectedNetwork = networks?.find(
(n) =>
n.id ===
(selectableNetworks.includes(watchNetwork)
? watchNetwork
: selectableNetworks[0]),
);
if (selectedNetwork) {
const { prefix, category } = selectedNetwork.accountNameInfo.default;
if (typeof prefix !== 'undefined') {
const id = wallet?.nextAccountIds?.[category] || 0;
setValue('name', `${prefix} #${id + 1}`);
}
}
}, [wallet, networks, watchNetwork, setValue]);
}, [wallet, networks, watchNetwork, selectableNetworks, setValue]);

const authenticationDone = useCallback(
async (password: string) => {
Expand Down Expand Up @@ -116,7 +135,11 @@ const CreateAccount: FC<CreateAccountProps> = ({ onClose }) => {
scrollViewProps={{
children: (
<Form w="full" zIndex={999} h="full">
<FormChainSelector control={control} name="network" />
<FormChainSelector
selectableNetworks={selectableNetworks}
control={control}
name="network"
/>
<Form.Item
name="name"
rules={{
Expand Down

0 comments on commit f83baff

Please sign in to comment.