Skip to content

Commit

Permalink
Merge branch 'onekey' into v4-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
originalix authored May 9, 2024
2 parents d533bcf + 74074aa commit 13979e4
Show file tree
Hide file tree
Showing 33 changed files with 175 additions and 73 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
"@onekeyfe/cross-inpage-provider-injected": "1.1.59",
"@onekeyfe/cross-inpage-provider-types": "1.1.59",
"@onekeyfe/extension-bridge-hosted": "1.1.59",
"@onekeyfe/hd-ble-sdk": "0.3.44",
"@onekeyfe/hd-core": "0.3.44",
"@onekeyfe/hd-shared": "0.3.44",
"@onekeyfe/hd-transport": "0.3.44",
"@onekeyfe/hd-web-sdk": "0.3.44",
"@onekeyfe/hd-ble-sdk": "0.3.46",
"@onekeyfe/hd-core": "0.3.46",
"@onekeyfe/hd-shared": "0.3.46",
"@onekeyfe/hd-transport": "0.3.46",
"@onekeyfe/hd-web-sdk": "0.3.46",
"@onekeyfe/onekey-cross-webview": "1.1.59",
"@starcoin/starcoin": "2.1.5",
"@web3-react/core": "8.0.35-beta.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "تبادل أي رموز",
"content__existing": "موجود",
"content__exit_value": "قيمة الخروج",
"content__export_tracking_key": "تصدير مفتاح التتبع",
"content__export_tracking_key_desc": "يتم استخدام مفتاح التتبع لإنشاء دليل على الأصول.",
"content__ext_metamask_tutorials_1": "انقر على الصورة الرمزية في الشريط العلوي",
"content__external_account": "الحسابات الخارجية",
"content__face_id": "معرف الوجه",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "যেকোনো টোকেন বিনিময় করুন",
"content__existing": "বিদ্যমান",
"content__exit_value": "প্রস্থান মান",
"content__export_tracking_key": "এক্সপোর্ট ট্র্যাকিং কী",
"content__export_tracking_key_desc": "ট্র্যাকিং কী ব্যবহার করা হয় সম্পদের প্রমাণ তৈরি করার জন্য।",
"content__ext_metamask_tutorials_1": "উপরের বারে Avatar-এ ক্লিক করুন",
"content__external_account": "বাহ্যিক অ্যাকাউন্ট",
"content__face_id": "ফেস আইডি",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Tauschen Sie alle Token aus",
"content__existing": "Vorhandenen",
"content__exit_value": "Ausgangswert",
"content__export_tracking_key": "Tracking-Schlüssel exportieren",
"content__export_tracking_key_desc": "Der Tracking-Schlüssel wird zum Generieren von Vermögensnachweisen verwendet.",
"content__ext_metamask_tutorials_1": "Klicken Sie auf den Avatar in der oberen Leiste",
"content__external_account": "Externe Konten",
"content__face_id": "Gesichts-ID",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Exchange any tokens",
"content__existing": "Existing",
"content__exit_value": "Exit Value",
"content__export_tracking_key": "Export Tracking Key",
"content__export_tracking_key_desc": "Tracking Key is used for generating proof of assets.",
"content__ext_metamask_tutorials_1": "Click on the Avatar in the Top bar",
"content__external_account": "External Accounts",
"content__face_id": "Face ID",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Intercambia cualquier token",
"content__existing": "Existente",
"content__exit_value": "Valor de salida",
"content__export_tracking_key": "Clave de seguimiento de exportaciones",
"content__export_tracking_key_desc": "La clave de seguimiento se utiliza para generar pruebas de activos.",
"content__ext_metamask_tutorials_1": "Haz clic en el Avatar en la barra superior",
"content__external_account": "Cuentas externas",
"content__face_id": "Face ID",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/fil.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Palitan ng anumang mga token",
"content__existing": "Umiiral",
"content__exit_value": "Exit Value",
"content__export_tracking_key": "I-export ang Tracking Key",
"content__export_tracking_key_desc": "Ginagamit ang Tracking Key para sa pagbuo ng patunay ng mga asset.",
"content__ext_metamask_tutorials_1": "Mag-click sa Avatar sa Top bar",
"content__external_account": "Mga Panlabas na Account",
"content__face_id": "Face ID",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Échangez des jetons",
"content__existing": "Existant",
"content__exit_value": "Valeur de sortie",
"content__export_tracking_key": "Clé de suivi des exportations",
"content__export_tracking_key_desc": "La clé de suivi est utilisée pour générer une preuve d’actifs.",
"content__ext_metamask_tutorials_1": "Cliquez sur l'avatar dans la barre supérieure",
"content__external_account": "Comptes externes",
"content__face_id": "Identification faciale",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/hi_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "किसी भी टोकन का आदान-प्रदान करें",
"content__existing": "मौजूदा",
"content__exit_value": "बाहर निकलें मूल्य",
"content__export_tracking_key": "ट्रैकिंग कुंजी निर्यात करें",
"content__export_tracking_key_desc": "ट्रैकिंग कुंजी का उपयोग परिसंपत्तियों का प्रमाण तैयार करने के लिए किया जाता है।",
"content__ext_metamask_tutorials_1": "टॉप बार में अवतार पर क्लिक करें",
"content__external_account": "बाहरी खाते",
"content__face_id": "फेस आईडी",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Tukarkan token apa pun",
"content__existing": "Ada",
"content__exit_value": "Nilai Keluar",
"content__export_tracking_key": "Ekspor Kunci Pelacakan",
"content__export_tracking_key_desc": "Kunci Pelacakan digunakan untuk menghasilkan bukti aset.",
"content__ext_metamask_tutorials_1": "Klik pada Avatar di bilah Atas",
"content__external_account": "Akun Eksternal",
"content__face_id": "ID wajah",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Scambia qualsiasi token",
"content__existing": "Esistente",
"content__exit_value": "Valore di uscita",
"content__export_tracking_key": "Chiave di tracciamento dell'esportazione",
"content__export_tracking_key_desc": "La chiave di tracciamento viene utilizzata per generare prove delle risorse.",
"content__ext_metamask_tutorials_1": "Fare clic sull'Avatar nella barra in alto",
"content__external_account": "Conti esterni",
"content__face_id": "ID viso",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "任意のトークンを交換する",
"content__existing": "既に存在",
"content__exit_value": "終了値",
"content__export_tracking_key": "エクスポートトラッキングキー",
"content__export_tracking_key_desc": "トラッキングキーは、資産の証明を生成するために使用されます。",
"content__ext_metamask_tutorials_1": "トップバーのアバターをクリック",
"content__external_account": "外部アカウント",
"content__face_id": "顔認証",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/ko_KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "모든 토큰 교환",
"content__existing": "기존의",
"content__exit_value": "종료 값",
"content__export_tracking_key": "추적 키 내보내기",
"content__export_tracking_key_desc": "추적 키는 자산 증명을 생성하는 데 사용됩니다.",
"content__ext_metamask_tutorials_1": "상단 표시줄에서 아바타를 클릭합니다.",
"content__external_account": "외부 계정",
"content__face_id": "페이스 아이디",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/mn_MN.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Аливаа жетон солилцох",
"content__existing": "Одоо байгаа",
"content__exit_value": "Утга гарах",
"content__export_tracking_key": "Экспортын хяналтын түлхүүр",
"content__export_tracking_key_desc": "Хяналтын түлхүүрийг хөрөнгийн нотлох баримт бүрдүүлэхэд ашигладаг.",
"content__ext_metamask_tutorials_1": "Дээд талбар дахь Аватар дээр дарна уу",
"content__external_account": "Гадаад дансууд",
"content__face_id": "Нүүрний ID",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Troque qualquer token",
"content__existing": "Existir",
"content__exit_value": "Valor de saída",
"content__export_tracking_key": "Chave de rastreamento de exportação",
"content__export_tracking_key_desc": "A chave de rastreamento é usada para gerar prova de ativos.",
"content__ext_metamask_tutorials_1": "Clique no Avatar na barra superior",
"content__external_account": "Contas externas",
"content__face_id": "ID de rosto",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Trocar qualquer token",
"content__existing": "Existente",
"content__exit_value": "Valor de saída",
"content__export_tracking_key": "Chave de rastreamento de exportação",
"content__export_tracking_key_desc": "A chave de rastreamento é usada para gerar prova de ativos.",
"content__ext_metamask_tutorials_1": "Clique no Avatar na barra superior",
"content__external_account": "Contas externas",
"content__face_id": "ID facial",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Обмен любых токенов",
"content__existing": "Существующий",
"content__exit_value": "Выходное значение",
"content__export_tracking_key": "Экспортировать ключ отслеживания",
"content__export_tracking_key_desc": "Ключ отслеживания используется для создания подтверждения активов.",
"content__ext_metamask_tutorials_1": "Нажмите на аватарку в верхней панели",
"content__external_account": "Внешние аккаунты",
"content__face_id": "Идентификатор лица",
Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/locale/th_TH.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "แลกเปลี่ยนโทเค็นใด ๆ",
"content__existing": "ที่มีอยู่เดิม",
"content__exit_value": "ค่าทางออก",
"content__export_tracking_key": "ส่งออกคีย์การติดตาม",
"content__export_tracking_key_desc": "รหัสติดตามใช้ในการสร้างหลักฐานสินทรัพย์",
"content__ext_metamask_tutorials_1": "คลิกที่รูปอวาตาร์ในแถบด้านบน",
"content__external_account": "บัญชีภายนอก",
"content__face_id": "รหัสประจำตัว",
Expand Down Expand Up @@ -670,7 +672,7 @@
"content__hardware_wallet_does_not_support_str_yet": "Hardware wallet ยังไม่รองรับ {0}",
"content__hardware_wallets_do_not_support_this_feature": "ไม่รองรับ Hardware Wallet",
"content__hardware_wallets_do_not_support_this_feature_desc": "ฟีเจอร์นี้ใช้ได้เฉพาะกับการชำระเงินด่วนของแอพวอลเล็ต ฮาร์ดแวร์วอลเล็ทยังคงต้องการการยืนยันจากฮาร์ดแวร์",
"content__hash": "กัญชา",
"content__hash": "แฮช",
"content__have_been_connected": "เชื่อมต่อก่อนหน้านี้",
"content__have_you_been_spared_this_year_we_hope_you_re_the": "ปีนี้คุณรอดแล้วหรือยัง?\n เราหวังว่าคุณจะเป็น...",
"content__height": "ส่วนสูง",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/uk_UA.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Обміняйте будь-які токени",
"content__existing": "Існуючий",
"content__exit_value": "Значення виходу",
"content__export_tracking_key": "Ключ відстеження експорту",
"content__export_tracking_key_desc": "Ключ відстеження використовується для створення підтвердження активів.",
"content__ext_metamask_tutorials_1": "Натисніть на аватар у верхній панелі",
"content__external_account": "Зовнішні облікові записи",
"content__face_id": "Face ID",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "Trao đổi bất kỳ mã thông báo nào",
"content__existing": "Hiện có",
"content__exit_value": "Giá trị thoát",
"content__export_tracking_key": "Xuất khóa theo dõi",
"content__export_tracking_key_desc": "Khóa theo dõi được sử dụng để tạo bằng chứng về tài sản.",
"content__ext_metamask_tutorials_1": "Nhấp vào Hình đại diện ở thanh trên cùng",
"content__external_account": "Tài khoản bên ngoài",
"content__face_id": "Face ID",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "兑换任何代币",
"content__existing": "已存在",
"content__exit_value": "离场价",
"content__export_tracking_key": "导出跟踪密钥",
"content__export_tracking_key_desc": "跟踪密钥用于生成资产证明。",
"content__ext_metamask_tutorials_1": "点击顶部栏中的「头像」",
"content__external_account": "外部账户",
"content__face_id": "面容识别",
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/locale/zh_HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
"content__exchange_any_tokens": "兌換任何代幣",
"content__existing": "現存的",
"content__exit_value": "離場價",
"content__export_tracking_key": "導出跟踪密鑰",
"content__export_tracking_key_desc": "追蹤密鑰用於產生資產證明。",
"content__ext_metamask_tutorials_1": "點擊頂部欄中的「頭像」",
"content__external_account": "外部賬戶",
"content__face_id": "人臉識別",
Expand Down
1 change: 1 addition & 0 deletions packages/engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ class Engine {
'111111': OnekeyNetwork.kaspa,
'29223': OnekeyNetwork.nexa,
'1900': OnekeyNetwork.xna,
'29538': OnekeyNetwork.dnx,
}[coinType];
if (typeof networkId === 'undefined') {
throw new NotImplemented('Unsupported network.');
Expand Down
1 change: 1 addition & 0 deletions packages/engine/src/types/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum AccountCredentialType {
PrivateKey = 'PrivateKey',
PrivateViewKey = 'PrivateViewKey',
PrivateSpendKey = 'PrivateSpendKey',
TrackingKey = 'TrackingKey',
Mnemonic = 'Mnemonic',
}

Expand Down
15 changes: 15 additions & 0 deletions packages/engine/src/vaults/impl/dynex/KeyringHardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,19 @@ 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);
}
}
29 changes: 23 additions & 6 deletions packages/engine/src/vaults/impl/dynex/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
InsufficientBalance,
InvalidAddress,
NotImplemented,
OneKeyInternalError,
} from '../../../errors';
import { AccountCredentialType } from '../../../types/account';
import {
type IApproveInfo,
type IDecodedTx,
Expand All @@ -34,7 +36,6 @@ import { KeyringImported } from './KeyringImported';
import { KeyringWatching } from './KeyringWatching';
import settings from './settings';

import type { AccountCredentialType } from '../../../types/account';
import type {
PartialTokenInfo,
TransactionStatus,
Expand Down Expand Up @@ -129,11 +130,22 @@ export default class Vault extends VaultBase {
};
}

override getExportedCredential(
override async getExportedCredential(
password: string,
credentialType: AccountCredentialType,
): Promise<string> {
throw new Error('Method not implemented.');
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 fetchTokenInfos(
Expand Down Expand Up @@ -487,16 +499,21 @@ export default class Vault extends VaultBase {

if (transaction.address_from === accountAddress) {
transaction.inputs.forEach((input) => {
const output = unspentOutputs[input.data.input.key_offsets[0]];
const output =
unspentOutputs[
`${input.data.input.key_offsets[0]}_${input.data.input.amount}`
];
if (output && output.amount === input.data.input.amount) {
delete unspentOutputs[input.data.input.key_offsets[0]];
delete unspentOutputs[
`${input.data.input.key_offsets[0]}_${input.data.input.amount}`
];
}
});
}

transaction.outputs?.forEach((output, index) => {
if (output.address_to === accountAddress) {
unspentOutputs[output.globalIndex] = {
unspentOutputs[`${output.globalIndex}_${output.output.amount}`] = {
prevIndex: index,
globalIndex: output.globalIndex,
txPubkey: transaction.extra.publicKey,
Expand Down
12 changes: 11 additions & 1 deletion packages/engine/src/vaults/impl/dynex/settings.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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: false,
privateKeyExportEnabled: true,
tokenEnabled: false,
txCanBeReplaced: false,

Expand Down Expand Up @@ -37,6 +40,13 @@ 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,6 +10,7 @@ export enum ManageAccountKeys {
ExportSecretMnemonic = 'ExportSecretMnemonic',
ExportPrivateViewKey = 'ExportPrivateViewKey',
ExportPrivateSpendKey = 'ExportPrivateSpendKey',
ExportTrackingKey = 'ExportTrackingKey',
HardwareCanNotExportPrivateKey = 'HardwareCanNotExportPrivateKey',
RemoveAccount = 'RemoveAccount',
}
Expand All @@ -18,6 +19,7 @@ export const SpecialExportCredentialKeys = [
ManageAccountKeys.ExportPrivateViewKey,
ManageAccountKeys.ExportPrivateSpendKey,
ManageAccountKeys.ExportSecretMnemonic,
ManageAccountKeys.ExportTrackingKey,
];

export const getManageAccountOptions: (
Expand Down Expand Up @@ -48,6 +50,18 @@ export const getManageAccountOptions: (
key: 'action__export_private_key',
},
},

[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: 2 additions & 1 deletion packages/kit/src/views/ManagerAccount/AccountInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ const ManagerAccountModal: FC = () => {
case ManageAccountKeys.ExportPrivateKey:
case ManageAccountKeys.ExportPrivateSpendKey:
case ManageAccountKeys.ExportPrivateViewKey:
case ManageAccountKeys.ExportSecretMnemonic: {
case ManageAccountKeys.ExportSecretMnemonic:
case ManageAccountKeys.ExportTrackingKey: {
if (item.credentialInfo) {
navigation.navigate(RootRoutes.Modal, {
screen: ModalRoutes.ManagerAccount,
Expand Down
Loading

0 comments on commit 13979e4

Please sign in to comment.