From 1461511c5da6b37b9f65027dcf9eb2e9c3effe8b Mon Sep 17 00:00:00 2001
From: hzrd149 <github@hzrd149.com>
Date: Mon, 18 Nov 2024 10:57:32 -0600
Subject: [PATCH] fix amber and serial port signers

---
 src/classes/accounts/amber-account.ts       |  3 ++-
 src/classes/accounts/serial-port-account.ts |  3 ++-
 src/services/amber-signer.ts                |  8 --------
 src/services/serial-port.ts                 | 14 --------------
 src/views/signin/start.tsx                  |  8 ++++----
 5 files changed, 8 insertions(+), 28 deletions(-)
 delete mode 100644 src/services/amber-signer.ts
 delete mode 100644 src/services/serial-port.ts

diff --git a/src/classes/accounts/amber-account.ts b/src/classes/accounts/amber-account.ts
index f2e3c446e..a98facab2 100644
--- a/src/classes/accounts/amber-account.ts
+++ b/src/classes/accounts/amber-account.ts
@@ -1,4 +1,4 @@
-import { AmberClipboardSigner } from "applesauce-signer";
+import { AmberClipboardSigner } from "applesauce-signer/signers/amber-clipboard-signer";
 import { Account } from "./account";
 
 export default class AmberAccount extends Account {
@@ -15,5 +15,6 @@ export default class AmberAccount extends Account {
   constructor(pubkey: string) {
     super(pubkey);
     this.signer = new AmberClipboardSigner();
+    this.signer.pubkey = pubkey;
   }
 }
diff --git a/src/classes/accounts/serial-port-account.ts b/src/classes/accounts/serial-port-account.ts
index 82b7d644b..3129e56ee 100644
--- a/src/classes/accounts/serial-port-account.ts
+++ b/src/classes/accounts/serial-port-account.ts
@@ -1,4 +1,4 @@
-import { SerialPortSigner } from "applesauce-signer";
+import { SerialPortSigner } from "applesauce-signer/signers/serial-port-signer";
 import { Account } from "./account";
 
 export default class SerialPortAccount extends Account {
@@ -14,5 +14,6 @@ export default class SerialPortAccount extends Account {
   constructor(pubkey: string) {
     super(pubkey);
     this.signer = new SerialPortSigner();
+    this.signer.pubkey = pubkey;
   }
 }
diff --git a/src/services/amber-signer.ts b/src/services/amber-signer.ts
deleted file mode 100644
index 4ee09a850..000000000
--- a/src/services/amber-signer.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { AmberClipboardSigner } from "applesauce-signer";
-import { alwaysVerify } from "./verify-event";
-
-/** @deprecated use AmberClipboardSigner class instead */
-const amberSignerService = new AmberClipboardSigner();
-amberSignerService.verifyEvent = alwaysVerify;
-
-export default amberSignerService;
diff --git a/src/services/serial-port.ts b/src/services/serial-port.ts
deleted file mode 100644
index 39e961323..000000000
--- a/src/services/serial-port.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { SerialPortSigner } from "applesauce-signer";
-import { alwaysVerify } from "./verify-event";
-
-/** @deprecated use SerialPortSigner class instead */
-const serialPortService = new SerialPortSigner();
-serialPortService.verifyEvent = alwaysVerify;
-
-setInterval(() => {
-  if (serialPortService.isConnected) {
-    serialPortService.ping();
-  }
-}, 1000 * 10);
-
-export default serialPortService;
diff --git a/src/views/signin/start.tsx b/src/views/signin/start.tsx
index ae091fa83..bfc5225cd 100644
--- a/src/views/signin/start.tsx
+++ b/src/views/signin/start.tsx
@@ -9,8 +9,6 @@ import UsbFlashDrive from "../../components/icons/usb-flash-drive";
 import HelpCircle from "../../components/icons/help-circle";
 
 import accountService from "../../services/account";
-import serialPortService from "../../services/serial-port";
-import amberSignerService from "../../services/amber-signer";
 import { AtIcon } from "../../components/icons";
 import Package from "../../components/icons/package";
 import Eye from "../../components/icons/eye";
@@ -47,7 +45,8 @@ export default function LoginStartView() {
       try {
         setLoading(true);
 
-        const pubkey = await serialPortService.getPublicKey();
+        const signer = new SerialPortSigner();
+        const pubkey = await signer.getPublicKey();
         accountService.addAccount(new SerialPortAccount(pubkey));
         accountService.switchAccount(pubkey);
       } catch (e) {
@@ -61,7 +60,8 @@ export default function LoginStartView() {
 
   const signinWithAmber = async () => {
     try {
-      const pubkey = await amberSignerService.getPublicKey();
+      const signer = new AmberClipboardSigner();
+      const pubkey = await signer.getPublicKey();
       accountService.addAccount(new AmberAccount(pubkey));
       accountService.switchAccount(pubkey);
     } catch (e) {