Skip to content

Commit

Permalink
Merge branch 'onekey' into fix/nexa-too-many-vins
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming authored May 9, 2024
2 parents 1eebebb + a82faf4 commit 6080b62
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 63 deletions.
1 change: 0 additions & 1 deletion packages/engine/src/types/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ enum AccountCredentialType {
PrivateKey = 'PrivateKey',
PrivateViewKey = 'PrivateViewKey',
PrivateSpendKey = 'PrivateSpendKey',
TrackingKey = 'TrackingKey',
Mnemonic = 'Mnemonic',
}

Expand Down
15 changes: 0 additions & 15 deletions packages/engine/src/vaults/impl/dynex/KeyringHardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,4 @@ export class KeyringHardware extends KeyringHardwareBase {
override signMessage(): Promise<string[]> {
throw new Error('Method not implemented.');
}

async getTrackingKey(params: { path: string }): Promise<string> {
const HardwareSDK = await this.getHardwareSDKInstance();
const { connectId, deviceId } = await this.getHardwareInfo();
const passphraseState = await this.getWalletPassphraseState();
const resp = await HardwareSDK.dnxGetTrackingKey(connectId, deviceId, {
path: params.path,
...passphraseState,
});

if (resp.success && !!resp.payload?.trackingKey) {
return resp.payload?.trackingKey;
}
throw convertDeviceError(resp.payload);
}
}
19 changes: 2 additions & 17 deletions packages/engine/src/vaults/impl/dynex/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
NotImplemented,
OneKeyInternalError,
} from '../../../errors';
import { AccountCredentialType } from '../../../types/account';
import {
type IApproveInfo,
type IDecodedTx,
Expand Down Expand Up @@ -130,22 +129,8 @@ export default class Vault extends VaultBase {
};
}

override async getExportedCredential(
password: string,
credentialType: AccountCredentialType,
): Promise<string> {
if (
this.accountId.startsWith('hw-') &&
credentialType === AccountCredentialType.TrackingKey
) {
const path = await this.getAccountPath();

return (this.keyring as KeyringHardware).getTrackingKey({ path });
}

throw new OneKeyInternalError(
'Only tracking key of HW accounts can be exported',
);
override async getExportedCredential(): Promise<string> {
throw new Error('Method not implemented.');
}

override fetchTokenInfos(
Expand Down
12 changes: 1 addition & 11 deletions packages/engine/src/vaults/impl/dynex/settings.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import type { LocaleIds } from '@onekeyhq/components/src/locale';
import {
COINTYPE_DYNEX,
INDEX_PLACEHOLDER,
} from '@onekeyhq/shared/src/engine/engineConsts';

import { AccountCredentialType } from '../../../types/account';

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

const settings: IVaultSettings = Object.freeze({
feeInfoEditable: false,
privateKeyExportEnabled: true,
privateKeyExportEnabled: false,
tokenEnabled: false,
txCanBeReplaced: false,

Expand Down Expand Up @@ -40,13 +37,6 @@ const settings: IVaultSettings = Object.freeze({
subDesc: `m/44'/${COINTYPE_DYNEX}'/0'/0'/x'`,
},
},

exportCredentialInfo: [
{
type: AccountCredentialType.TrackingKey,
key: 'content__export_tracking_key' as LocaleIds,
},
],
});

export default settings;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export enum ManageAccountKeys {
ExportSecretMnemonic = 'ExportSecretMnemonic',
ExportPrivateViewKey = 'ExportPrivateViewKey',
ExportPrivateSpendKey = 'ExportPrivateSpendKey',
ExportTrackingKey = 'ExportTrackingKey',
HardwareCanNotExportPrivateKey = 'HardwareCanNotExportPrivateKey',
RemoveAccount = 'RemoveAccount',
}
Expand All @@ -19,7 +18,6 @@ export const SpecialExportCredentialKeys = [
ManageAccountKeys.ExportPrivateViewKey,
ManageAccountKeys.ExportPrivateSpendKey,
ManageAccountKeys.ExportSecretMnemonic,
ManageAccountKeys.ExportTrackingKey,
];

export const getManageAccountOptions: (
Expand Down Expand Up @@ -51,17 +49,6 @@ export const getManageAccountOptions: (
},
},

[ManageAccountKeys.ExportTrackingKey]: {
label: intl.formatMessage({ id: 'content__export_tracking_key' }),
description: intl.formatMessage({
id: 'content__export_tracking_key_desc',
}),
key: ManageAccountKeys.ExportTrackingKey,
credentialInfo: {
type: AccountCredentialType.TrackingKey,
key: 'content__export_tracking_key',
},
},
[ManageAccountKeys.ExportPrivateViewKey]: {
label: intl.formatMessage({ id: 'action__export_private_view_key' }),
description: intl.formatMessage({
Expand Down
3 changes: 1 addition & 2 deletions packages/kit/src/views/ManagerAccount/AccountInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ const ManagerAccountModal: FC = () => {
case ManageAccountKeys.ExportPrivateKey:
case ManageAccountKeys.ExportPrivateSpendKey:
case ManageAccountKeys.ExportPrivateViewKey:
case ManageAccountKeys.ExportSecretMnemonic:
case ManageAccountKeys.ExportTrackingKey: {
case ManageAccountKeys.ExportSecretMnemonic: {
if (item.credentialInfo) {
navigation.navigate(RootRoutes.Modal, {
screen: ModalRoutes.ManagerAccount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ export function useAccountInfoDataSource({
}
if (
privateKeyExportEnabled &&
(wallet.type === 'hd' ||
wallet.type === 'imported' ||
(wallet.type === 'hw' && network.impl === IMPL_DYNEX))
(wallet.type === 'hd' || wallet.type === 'imported')
) {
if (exportCredentialInfo) {
SpecialExportCredentialKeys.forEach((key) => {
Expand All @@ -70,7 +68,7 @@ export function useAccountInfoDataSource({
keys.push(ManageAccountKeys.ExportPrivateKey);
}
}
if (wallet.type === 'hw' && network.impl !== IMPL_DYNEX) {
if (wallet.type === 'hw') {
keys.push(ManageAccountKeys.HardwareCanNotExportPrivateKey);
}
keys.push(ManageAccountKeys.RemoveAccount);
Expand Down

0 comments on commit 6080b62

Please sign in to comment.