+ Please enter your PIN directly on the {deviceName} screen. After the
+ device is unlocked, click the button below.
+
+ {model &&
@@ -115,7 +129,7 @@ const TrezorPinModal = ({
className={styles.loadingSpinner}
/>
) : (
- "Enter Pin"
+ "Enter PIN"
)}
),
diff --git a/src/modals/index.ts b/src/modals/index.ts
index 7ef0f5d..c20f014 100644
--- a/src/modals/index.ts
+++ b/src/modals/index.ts
@@ -4,4 +4,5 @@ export { default as DeviceNotFoundModal } from "./DeviceNotFoundModal/DeviceNotF
export { default as MultipleDevicesModal } from "./MultipleDevicesModal/MultipleDevicesModal";
export { default as ErrorModal } from "./ErrorModal/ErrorModal";
export { default as TrezorPinModal } from "./TrezorPinModal/TrezorPinModal";
+export { default as OneKeyPinModal } from "./OneKeyPinModal/OneKeyPinModal";
export { default as SubscriptionsModal } from "./SubscriptionsModal/SubscriptionsModal";
diff --git a/src/screens/ConnectScreen/ConnectScreen.tsx b/src/screens/ConnectScreen/ConnectScreen.tsx
index 38d4ae5..d6bddda 100644
--- a/src/screens/ConnectScreen/ConnectScreen.tsx
+++ b/src/screens/ConnectScreen/ConnectScreen.tsx
@@ -10,6 +10,7 @@ import { listen } from "@tauri-apps/api/event";
import QRCode from "qrcode.react";
import useModalState from "../../hooks/useModalState";
import {
+ getPinInteractionType,
HWI_ACTION,
HWIDevice,
HWIDeviceType,
@@ -57,6 +58,7 @@ const ConnectScreen = () => {
const [expectedAddress, setExpectedAddress] = useState
(null);
const [errorMessage, setErrorMessage] = useState("");
const [pairingCode, setPairingCode] = useState(null);
+ const [currentDevice, setCurrentDevice] = useState(null);
// Subscriptions state variables
const [isSubscriptionsModalOpen, setSubscriptionsModalOpen] = useState(false);
@@ -70,14 +72,22 @@ const ConnectScreen = () => {
openModalHandler("notFound");
} else {
if (deviceType && network) {
+ const device = devices[0];
+ setCurrentDevice(device);
await hwiService.setHWIClient(
- devices[0].fingerprint,
+ device.fingerprint,
deviceType,
network.toLowerCase(),
);
- if (devices[0].needs_pin_sent) {
+ if (device.needs_pin_sent) {
await hwiService.promptPin();
- openModalHandler("pin");
+ const pinInteractionType = getPinInteractionType(
+ deviceType,
+ device.model,
+ );
+ openModalHandler(
+ pinInteractionType === "device" ? "onekeyPin" : "pin",
+ );
} else {
openModalHandler("deviceActionSuccess");
}
@@ -155,6 +165,10 @@ const ConnectScreen = () => {
}
break;
case "REGISTER_MULTISIG":
+ if (data.signerType?.toLowerCase() === "onekey") {
+ handleError("Register multisig is not supported on OneKey");
+ return;
+ }
setActionType("registerMultisig");
if (data.descriptorString) {
setDescriptor(data.descriptorString.replace(/\*\*/g, "0/0"));
@@ -329,6 +343,7 @@ const ConnectScreen = () => {
setCurrentAction={setCurrentAction}
openModalHandler={openModalHandler}
pairingCode={pairingCode}
+ currentDevice={currentDevice}
/>
)}
Version {version}
diff --git a/src/services/hwiService.ts b/src/services/hwiService.ts
index c094b92..be1002c 100644
--- a/src/services/hwiService.ts
+++ b/src/services/hwiService.ts
@@ -15,6 +15,12 @@ const emptyTrezorDevice: HWIDevice = {
fingerprint: null,
};
+let currentDeviceType: string | null = null;
+
+const emitToChannel = async (eventData: unknown) => {
+ await invoke("emit_to_channel", { eventData });
+};
+
const hwiService = {
fetchDevices: async (
deviceType: HWIDeviceType | null = null,
@@ -50,6 +56,8 @@ const hwiService = {
deviceType: string,
network: string,
): Promise => {
+ currentDeviceType = deviceType;
+
if (network === "mainnet") {
network = "bitcoin";
}
@@ -58,12 +66,12 @@ const hwiService = {
shareXpubs: async (account: number): Promise => {
const eventData = await invoke("hwi_get_xpubs", { account });
- await invoke("emit_to_channel", { eventData });
+ await emitToChannel(eventData);
},
performHealthCheck: async (account: number): Promise => {
const eventData = await invoke("hwi_healthcheck", { account });
- await invoke("emit_to_channel", { eventData });
+ await emitToChannel(eventData);
},
signTx: async (
@@ -78,7 +86,7 @@ const hwiService = {
walletName,
hmac,
});
- await invoke("emit_to_channel", { eventData });
+ await emitToChannel(eventData);
},
registerMultisig: async (
@@ -87,13 +95,18 @@ const hwiService = {
walletName: string | null,
expectedAddress: string,
): Promise => {
+ if (currentDeviceType === "onekey") {
+ throw new Error("Operation not supported on OneKey");
+ }
+
const eventData = await invoke("hwi_register_multisig", {
descriptor,
policy,
walletName,
expectedAddress,
});
- await invoke("emit_to_channel", { eventData });
+
+ await emitToChannel(eventData);
},
verifyAddress: async (
@@ -112,7 +125,7 @@ const hwiService = {
hmac,
expectedAddress,
});
- await invoke("emit_to_channel", { eventData });
+ await emitToChannel(eventData);
},
promptPin: async (): Promise => {
diff --git a/vite.config.ts b/vite.config.ts
index 0c9adff..2ae2470 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -4,6 +4,9 @@ import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [react()],
+ define: {
+ global: "globalThis",
+ },
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//