From 86f17a5f6cf67d905fcd1711780ae440a37d4f3b Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Fri, 9 Aug 2024 14:42:36 -0300 Subject: [PATCH] fix: solve bugs related to hardwallet connection --- source/pages/Send/Confirm.tsx | 6 ++++++ source/pages/Settings/ConnectHardwareWallet.tsx | 5 +++-- source/routers/index.tsx | 4 ++-- source/scripts/Background/controllers/MainController.ts | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/pages/Send/Confirm.tsx b/source/pages/Send/Confirm.tsx index 5959c0cbe..e8b8027b0 100755 --- a/source/pages/Send/Confirm.tsx +++ b/source/pages/Send/Confirm.tsx @@ -121,6 +121,12 @@ export const SendConfirm = () => { // SYSCOIN TRANSACTIONS case isBitcoinBased === true: try { + if (activeAccount.isTrezorWallet) { + await wallet.trezorSigner.init(); + } + if (activeAccount.isLedgerWallet) { + await wallet.ledgerSigner.connectToLedgerDevice(); + } wallet.syscoinTransaction .sendTransaction( { ...basicTxValues, fee: 0.00001 }, diff --git a/source/pages/Settings/ConnectHardwareWallet.tsx b/source/pages/Settings/ConnectHardwareWallet.tsx index aaaad2c0e..227f030c1 100755 --- a/source/pages/Settings/ConnectHardwareWallet.tsx +++ b/source/pages/Settings/ConnectHardwareWallet.tsx @@ -66,7 +66,8 @@ const ConnectHardwareWalletView: FC = () => { try { switch (selectedHardwareWallet) { case 'trezor': - await controller.wallet.importTrezorAccount( + await controller.wallet.trezorSigner.init(); + await controller.wallet.importTrezorAccountFromController( isBitcoinBased ? activeNetwork.currency : 'eth', `${activeNetwork.currency === 'sys' ? '57' : slip44}`, `${trezorAccounts.length}` @@ -93,7 +94,7 @@ const ConnectHardwareWalletView: FC = () => { } if (webHidIsConnected) { - await controller.wallet.importLedgerAccount( + await controller.wallet.importLedgerAccountFromController( isBitcoinBased ? activeNetwork.currency : 'eth', `${activeNetwork.currency === 'sys' ? '57' : slip44}`, `${ledgerAccounts.length}`, diff --git a/source/routers/index.tsx b/source/routers/index.tsx index 9d92be0cb..0f96cd4f1 100644 --- a/source/routers/index.tsx +++ b/source/routers/index.tsx @@ -119,10 +119,10 @@ export const Router = () => { alert.removeAll(); // appRoute(pathname); const isFullscreen = window.innerWidth > 600; - if (isFullscreen) { + if (isFullscreen && isUnlocked) { navigate('/settings/account/hardware'); } - }, [pathname]); + }, [pathname, isUnlocked]); useEffect(() => { if ( diff --git a/source/scripts/Background/controllers/MainController.ts b/source/scripts/Background/controllers/MainController.ts index 7454a93b8..2d37978b7 100644 --- a/source/scripts/Background/controllers/MainController.ts +++ b/source/scripts/Background/controllers/MainController.ts @@ -805,7 +805,7 @@ class MainController extends KeyringManager { return importedAccount; } - public async importTrezorAccount( + public async importTrezorAccountFromController( coin: string, slip44: string, index: string @@ -864,7 +864,7 @@ class MainController extends KeyringManager { return importedAccount; } - public async importLedgerAccount( + public async importLedgerAccountFromController( coin: string, slip44: string, index: string,